home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume6 / lbl < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  67.5 KB

  1. Subject: v06i056:  lbl preprocessor for [nt*]roff (lbl)
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.UUCP
  4.  
  5. Submitted by: wjh12!maynard!campbell
  6. Mod.sources: Volume 6, Issue 56
  7. Archive-name: lbl
  8.  
  9. The following shar archive contains the lbl preprocessor for [nt*]roff.
  10. lbl handles generation of and symbolic references to sequenced labels,
  11. alphabetic, numeric, or mixed.  Forward references are supported.
  12.  
  13. Lbl was written by C.D.F. Miller at Heriot-Watt University (Scotland),
  14. and was originally posted to net.sources over a year ago.  It compiled
  15. and ran without a hitch on my tiny VENIX system and has performed
  16. flawlessly ever since; this is high praise indeed for a net.sources
  17. widget.  Hence, this shar archive contains the author's original code
  18. and documentation, untouched.  Share and enjoy.
  19.  
  20. #! /bin/sh
  21. # This is a shell archive, meaning:
  22. # 1. Remove everything above the #! /bin/sh line.
  23. # 2. Save the resulting text in a file.
  24. # 3. Execute the file with /bin/sh (not csh) to create:
  25. #    Introduction
  26. #    Makefile
  27. #    NOTICE
  28. #    READ.ME
  29. #    doc
  30. #    hdr
  31. #    src
  32. # This archive created: Thu Jul  3 23:27:04 1986
  33. export PATH; PATH=/bin:/usr/bin:$PATH
  34. echo shar: "extracting 'Introduction'" '(1433 characters)'
  35. if test -f 'Introduction'
  36. then
  37.     echo shar: "will not over-write existing file 'Introduction'"
  38. else
  39. sed 's/^    X//' << \SHAR_EOF > 'Introduction'
  40.     XThis is a distribution of a preprocessor, lbl, for nroff and its
  41.     Xkindred.  Lbl allows you to give symbolic labels to objects in a text
  42.     Xfile which belong in numbered sequences (e.g.  chapters, figures,
  43.     Xtables, equations) and to refer to them by name; sequence numbers are
  44.     Xassigned automatically.  Hence, it is unnecessary to adjust all
  45.     Xcross-references every time that a new item is inserted into the middle
  46.     Xof a sequence.
  47.     X
  48.     XMulti-level sequences are supported (similar to the multi-level section
  49.     Xnumbers in many macro packages); the user has control over the format
  50.     Xof each level of sequence numbers (roman, arabic, letters).  Many
  51.     Xindependent sequences may be used simultaneously, limited only by the
  52.     Xmemory available to the program; the same name may be used for items in
  53.     Xseveral sequences.
  54.     X
  55.     XThe program was written by Chris Miller at Heriot-Watt University,
  56.     XEdinburgh.  Please report bugs, portability problems or ideas for
  57.     Ximprovements to chris@hwcs.uucp ( ....!mcvax!ukc!kcl-cs!hwcs!chris if
  58.     Xyou need to be more explicit in your mail path).
  59.     X
  60.     XAs indicated in the attached NOTICE, you are free to pass this to
  61.     Xanyone else; it contains NO code restricted under proprietary
  62.     Xagreements.  If you make alterations, please (a) inform the author and
  63.     X(b) mark the emendations to the original distribution clearly
  64.     X(preferably through conditional compilation) -- I desire neither praise
  65.     Xfor your brilliance nor scorn for your incompetence!
  66.     X
  67. SHAR_EOF
  68. if test 1433 -ne "`wc -c < 'Introduction'`"
  69. then
  70.     echo shar: "error transmitting 'Introduction'" '(should have been 1433 characters)'
  71. fi
  72. fi
  73. echo shar: "extracting 'Makefile'" '(375 characters)'
  74. if test -f 'Makefile'
  75. then
  76.     echo shar: "will not over-write existing file 'Makefile'"
  77. else
  78. sed 's/^    X//' << \SHAR_EOF > 'Makefile'
  79.     X# (C) C.D.F.Miller, Heriot-Watt University, March 1984
  80.     X
  81.     XDESTDIR=/
  82.     XBIN=/usr/local
  83.     XMAN=/usr/man/man1
  84.     XDOC=/usr/doc
  85.     X
  86.     Xsrc/lbl:
  87.     X    cd src; make
  88.     X
  89.     Xinstall:    src/lbl
  90.     X    cp src/lbl $(DESTDIR)$(BIN)
  91.     X    strip $(DESTDIR)$(BIN)/lbl
  92.     X    cp doc/lbl.1 $(DESTDIR)$(MAN)
  93.     X    cp doc/lbl $(DESTDIR)$(DOC)
  94.     X
  95.     Xlbl.shar:
  96.     X    shar Introduction NOTICE READ.ME Makefile doc hdr src >lbl.shar
  97.     X
  98.     Xclean:
  99.     X    cd src; make clean
  100. SHAR_EOF
  101. if test 375 -ne "`wc -c < 'Makefile'`"
  102. then
  103.     echo shar: "error transmitting 'Makefile'" '(should have been 375 characters)'
  104. fi
  105. fi
  106. echo shar: "extracting 'NOTICE'" '(611 characters)'
  107. if test -f 'NOTICE'
  108. then
  109.     echo shar: "will not over-write existing file 'NOTICE'"
  110. else
  111. sed 's/^    X//' << \SHAR_EOF > 'NOTICE'
  112.     XNOTICE:
  113.     X
  114.     XThe software and documentation contained within this directory and
  115.     Xall its subdirectories is copyright (C) C.D.F. Miller, 1984, 1985.
  116.     X
  117.     XPermission is hereby given for its free reproduction and modification
  118.     Xfor non-commercial purposes, provided that this notice and all embedded
  119.     Xcopyright notices be retained.  Commercial organisations may give away
  120.     Xcopies as part of their systems provided that they do so without charge,
  121.     Xand that they acknowledge the source of the software.
  122.     X
  123.     X                C.D.F. Miller
  124.     X                Department of Computer Science
  125.     X                Heriot-Watt University
  126.     X                79 Grassmarket
  127.     X                Edinburgh
  128.     X                Scotland
  129. SHAR_EOF
  130. if test 611 -ne "`wc -c < 'NOTICE'`"
  131. then
  132.     echo shar: "error transmitting 'NOTICE'" '(should have been 611 characters)'
  133. fi
  134. fi
  135. echo shar: "extracting 'READ.ME'" '(107 characters)'
  136. if test -f 'READ.ME'
  137. then
  138.     echo shar: "will not over-write existing file 'READ.ME'"
  139. else
  140. sed 's/^    X//' << \SHAR_EOF > 'READ.ME'
  141.     Xdoc    contains manual page and more extensive guide
  142.     Xhdr    contains header files
  143.     Xsrc    contains the C source code
  144. SHAR_EOF
  145. if test 107 -ne "`wc -c < 'READ.ME'`"
  146. then
  147.     echo shar: "error transmitting 'READ.ME'" '(should have been 107 characters)'
  148. fi
  149. fi
  150. if test ! -d 'doc'
  151. then
  152.     echo shar: "creating directory 'doc'"
  153.     mkdir 'doc'
  154. fi
  155. echo shar: "entering directory 'doc'"
  156. cd 'doc'
  157. echo shar: "extracting 'Makefile'" '(187 characters)'
  158. if test -f 'Makefile'
  159. then
  160.     echo shar: "will not over-write existing file 'Makefile'"
  161. else
  162. sed 's/^    X//' << \SHAR_EOF > 'Makefile'
  163.     XLBL=lbl
  164.     XNROFF=nroff
  165.     XFILTER=cat
  166.     X
  167.     Xdoc:    lbl
  168.     X    $(LBL) lbl | $(NROFF) -ms | $(FILTER)
  169.     X
  170.     Xman:    lbl.1
  171.     X    $(NROFF) -man lbl.1 | $(FILTER)
  172.     X
  173.     Xexample:    example.n
  174.     X    lbl example.n | $(NROFF) -ms | $(FILTER)
  175. SHAR_EOF
  176. if test 187 -ne "`wc -c < 'Makefile'`"
  177. then
  178.     echo shar: "error transmitting 'Makefile'" '(should have been 187 characters)'
  179. fi
  180. fi
  181. echo shar: "extracting 'READ.ME'" '(548 characters)'
  182. if test -f 'READ.ME'
  183. then
  184.     echo shar: "will not over-write existing file 'READ.ME'"
  185. else
  186. sed 's/^    X//' << \SHAR_EOF > 'READ.ME'
  187.     XThe files in this directory are:
  188.     X
  189.     Xlbl.1    Manual page, to be installed in /usr/man/man1 or wherever
  190.     X    else you keep the pages for contributed user programs.
  191.     X
  192.     Xlbl    Longer manual; possibly to be installed in /usr/doc.  This
  193.     X    uses the "ms" macro package, which is still probably the
  194.     X    most widely available.  The command to generate the formatted
  195.     X    manual is
  196.     X        lbl lbl | nroff -ms
  197.     X
  198.     Xexample.n
  199.     X    A short example of the use of lbl.  This example is also
  200.     X    embedded within the manual in a different guise.
  201.     X
  202.     XMakefile
  203.     X    A very trivial Makefile for the documentation
  204. SHAR_EOF
  205. if test 548 -ne "`wc -c < 'READ.ME'`"
  206. then
  207.     echo shar: "error transmitting 'READ.ME'" '(should have been 548 characters)'
  208. fi
  209. fi
  210. echo shar: "extracting 'example.n'" '(850 characters)'
  211. if test -f 'example.n'
  212. then
  213.     echo shar: "will not over-write existing file 'example.n'"
  214. else
  215. sed 's/^    X//' << \SHAR_EOF > 'example.n'
  216.     X.\" (C) C.D.F. Miller, Heriot-Watt University, March 1984
  217.     X.\"
  218.     X.\"    We use '.L= sec' to generate the numbered headings
  219.     X.de L=
  220.     X.if '\\$1'sec' .NH \\$2
  221.     X..
  222.     X.ND
  223.     X.TL
  224.     XExample of LBL
  225.     X.L= sec 1 intro
  226.     XIntroduction
  227.     X.L= table 1 *
  228.     X.PP
  229.     XWe begin with a small table (Table @table opening@).
  230.     X.DS C
  231.     XTable @table opening@ about here
  232.     X.DE
  233.     Xand consider things in more detail in Section @sec cont@.
  234.     X.L= table 2 opening
  235.     X.L= sec 1 cont
  236.     XContinuation
  237.     X.L= table 1 *
  238.     X.PP
  239.     XIn this continuation we refer back to Section @sec intro@, which contained
  240.     XTable @table opening@, and presnt more detailed information in Table
  241.     X@table detail@.
  242.     X.DS
  243.     XTable @table detail@ about here.
  244.     X.DE
  245.     X.L= table 2 detail
  246.     X.L= sec 2 subcont
  247.     XSub-continuation
  248.     X.PP
  249.     XIn which we further refine things, as shown in Table @table mega-detail@ below.
  250.     X.DS
  251.     XTable @table mega-detail@ about here.
  252.     X.DE
  253.     X.L= table 2 mega-detail
  254. SHAR_EOF
  255. if test 850 -ne "`wc -c < 'example.n'`"
  256. then
  257.     echo shar: "error transmitting 'example.n'" '(should have been 850 characters)'
  258. fi
  259. fi
  260. echo shar: "extracting 'lbl'" '(9613 characters)'
  261. if test -f 'lbl'
  262. then
  263.     echo shar: "will not over-write existing file 'lbl'"
  264. else
  265. sed 's/^    X//' << \SHAR_EOF > 'lbl'
  266.     X.\" (C) C.D.F. Miller, Heriot-Watt University, March 1984
  267.     X.\"
  268.     X.\" This file should be formatted by
  269.     X.\"    lbl lbl | nroff -ms
  270.     X.L= delimiter #
  271.     X.ND
  272.     X.TL
  273.     XLBL - Symbolic Labels in Text Documents
  274.     X.NH 1
  275.     XIntroduction
  276.     X.L= sec 1 intro
  277.     X.PP
  278.     X.I lbl
  279.     Xis a pre-processor for
  280.     X.I troff
  281.     Xand
  282.     X.I nroff
  283.     Xwhich allows Sections, Figures, Tables, etc., to be referred to by
  284.     Xsymbolic names rather than by absolute number.
  285.     XIt will handle forward references as well as backward ones.
  286.     X.PP
  287.     XUses of a label in the text are indicated by a delimiter character (default '@',
  288.     Xbut resettable), followed by a
  289.     X.I type
  290.     Xname (e.g. "TABLE", "EQN", etc.), followed by the label itself
  291.     X(e.g. "Profits-1983").
  292.     XEach such occurrence is replaced by a reference number; the default
  293.     Xstyle of numbering is a sequence of period-separated arabic numbers
  294.     X(e.g. 2.4.1) but this is resettable.
  295.     XFinally, another delimiter is required to close the reference
  296.     X(cf. the use of delimiters in
  297.     X.I eqn
  298.     Xfor in-line equations).
  299.     X.LP
  300.     XExamples:
  301.     X.DS
  302.     XFor full details refer to Table @TABLE Profits-1983@.
  303.     XAs we saw in Chapter @chap intro@, ...
  304.     XFigure @fig wing-profile@ shows the airflow patterns ...
  305.     X.DE
  306.     X.PP
  307.     XLabels may be defined at any point in the text.
  308.     XThe definition looks like a
  309.     X.I troff
  310.     Xmacro, and the definition line is retained in the original text.
  311.     XBy default, the macro used is ".L=", but this can be reset.
  312.     XThe macro takes 3 arguments: a type-name, a level-number, and
  313.     Xa label-name.
  314.     X.PP
  315.     XThe type-name corresponds to that used to signal a label occurrence in
  316.     Xthe text.
  317.     XThere is no restriction on the choice of name; any sequence of
  318.     Xnon-blank characters may be used.
  319.     XUpper- and lower-case letters
  320.     X.I are
  321.     Xdistinguished.
  322.     X.PP
  323.     XThe level-number corresponds to the header-level numbers used
  324.     Xby the .NH macro in
  325.     X.I ms ,
  326.     Xthe .sh macro in
  327.     X.I me ,
  328.     Xetc.
  329.     XThe index at the given level is incremented by 1, and all higher indexes
  330.     Xset to 0.
  331.     XInitially, all indexes are set to 0 by default, but other starting values
  332.     Xmay be chosen.
  333.     XThere is an implementation-defined restriction on the number
  334.     Xof levels of index (currently 20);
  335.     Xit is not anticipated that this will lead to problems.
  336.     X.PP
  337.     XThe label may be any sequence of non-blank characters;
  338.     Xthe same label may be used in more than one type.
  339.     XFurthermore, the special label-name ``*'' can be used to increment the
  340.     Xappropriate level-counter without defining a label at all;
  341.     Xthis is useful, for example, when all tables, figures, etc., in a section
  342.     Xtake their initial index from the section number: two ways of doing this
  343.     Xwould be:
  344.     X.DS L
  345.     Xa.
  346.     X    .L= section 1 this-section
  347.     X    .L= last table 0
  348.     X    .L= last figure 0
  349.     X    ...
  350.     X    ... refer to table @section this-section@.@table profits@ ...
  351.     X    ... see figure @section this-section@.@figure structure@ ...
  352.     X    ...
  353.     X    .L= table 1 profits
  354.     X    ...
  355.     X    .L= figure 1 structure
  356.     X    ...
  357.     X
  358.     X(see section #sec directives# for the use of
  359.     X``.L=\ last\ ...'')
  360.     X
  361.     Xb.
  362.     X    .L= section 1 this-section
  363.     X    .L= table 1 *
  364.     X    .L= figure 1 *
  365.     X    ...
  366.     X    ... refer to table @table profits@ ...
  367.     X    ... see figure @figure structure@ ...
  368.     X    ...
  369.     X    .L= table 2 profits
  370.     X    ...
  371.     X    .L= figure 2 structure
  372.     X    ...
  373.     X.DE
  374.     XIt is largely a matter of taste which technique is used;
  375.     Xthe former is more long-winded, but avoids the need to remember to
  376.     Xkeep the tables and figures in step every time the section is
  377.     Xupdated.
  378.     XYet a third possibility (similar to the first) would be:
  379.     X.DS L
  380.     Xc.
  381.     X    .L= section 1 this-section
  382.     X    .ds Sc "@section this-section@
  383.     X    .L= last table 0
  384.     X    ...
  385.     X    ... refer to table \*(Sc.@table profits@
  386.     X    etc.
  387.     X.DE
  388.     Xmaking use of the string-definition facility within
  389.     X.I nroff .
  390.     X.PP
  391.     XIt is important to be aware that all processing on labels is done
  392.     Xbefore
  393.     X.I troff
  394.     Xprocesses the text; attempts to build label-references by
  395.     Xusing macros or
  396.     X.I troff
  397.     Xstrings registers will almost certainly not work as expected.
  398.     X.NH 1
  399.     XCommand Line Options
  400.     X.L= sec 1 options
  401.     X.PP
  402.     XOptions to
  403.     X.I lbl
  404.     Xare set in the command line, which has the form
  405.     X.DS
  406.     Xlbl [ -d\fIdelim\fR ] [ -m\fImacro\fR ] [ -l ] [ -s ]
  407.     X.DE
  408.     X.IP -d
  409.     X.I \fIdelim\fR
  410.     Xis the character used to delimit in-line occurrences of label
  411.     Xreferences (default ``@'');
  412.     X.IP -m
  413.     X.I macro
  414.     Xis the 2-character name of
  415.     Xa
  416.     X.I troff
  417.     Xmacro which introduces label definitions, etc. (default ``L='');
  418.     X.IP -l
  419.     Xcauses a listing of label-definitions to be written to the standard
  420.     Xerror stream.
  421.     XEach label-type is listed, together with its print format, followed by
  422.     Xa line for each label of that type, showing label-name, file and line
  423.     Xwhere it is defined, and value;
  424.     X.IP -s
  425.     Xcauses the generation of the
  426.     X.I troff
  427.     Xinput file to be suppressed;
  428.     Xsetting
  429.     X.I -s 
  430.     Xautomatically also sets
  431.     X.I -l .
  432.     X.NH 1
  433.     XControl directives
  434.     X.L= sec 1 directives
  435.     X.PP
  436.     XIn addition to defining labels, the \fB.L=\fR macro (or its substitute)
  437.     Xcan be used for several other purposes.
  438.     XThese are all indicated by commands of the form
  439.     X.DS
  440.     X\&.L= \fIcommand\fR \fIargument\fR ...
  441.     X.DE
  442.     Xwhere the \fIcommand\fRs are reserved words which may not be used as
  443.     Xtype-names.
  444.     XThese commands allow control over the initialisation of label values,
  445.     Xthe print format of labels, and thelabel reference delimiter.
  446.     X.IP "\&.L= delimiter off"
  447.     X.br
  448.     Xturns off interpretation of the delimiter character altogether;
  449.     Xsubsequent text is copied literally until another \fIdelimiter\fR
  450.     Xcommand is encountered;
  451.     X.IP "\&.L= delimiter \fIcharacter\fR"
  452.     X.br
  453.     Xresets the delimiter in subsequent text to the given character;
  454.     X.IP "\&.L= format \fItypename\fR \fIstring\fR"
  455.     X.br
  456.     Xsets the print format for labels of the given type - see section
  457.     X#sec formats#;
  458.     X.IP "\&.L= last \fItypename\fR \fIcount1\fR \fIcount2\fR ..."
  459.     X.br
  460.     Xresets the counters for \fItypename\fR as though the last label
  461.     Xgenerated had been \fIcount1.count2...\fR (with all omitted counts
  462.     Xtaken as 0).
  463.     X.NH 2
  464.     XPrint formats
  465.     X.L= sec 2 formats
  466.     X.PP
  467.     XThe default print format for a label is as a sequence of period-separated
  468.     Xarabic numerals.
  469.     XHowever, it is also possible to specify alphabetic or roman labels,
  470.     Xor a mixture, and to have separators other than a period.
  471.     XThis is governed by the format given in a ``.LE\ format'' command.
  472.     X.PP
  473.     XSuch a format contains escape sequences (flagged by a ``%'' character)
  474.     Xand literal text.
  475.     XThe text is copied until an escape sequence is encountered; such a
  476.     Xsequence is replaced by the index for the next level of the label
  477.     Xvalue, printed in one of the following formats:
  478.     X.IP %1
  479.     XArabic numerals (without non-significant leading zeros);
  480.     X.IP %0
  481.     XAs %1, but offset by 1 so that the first value printed will be 0 rather
  482.     Xthan 1;
  483.     X.IP %a
  484.     XLower-case alphabetics, starting at ``a''; ``z'' is followed by ``aa'',
  485.     Xetc.;
  486.     X.IP %A
  487.     XUpper-case alphabetics;
  488.     X.IP %i
  489.     XLower-case roman numerals (with some odd choices for large numbers,
  490.     Xconsistent with the roman numerals printed by
  491.     X.I troff ).
  492.     X.IP %I
  493.     XUpper-case roman numerals.
  494.     X.LP
  495.     XA ``%'' followed by any other character (in particular another ``%'') prints
  496.     Xas that character.
  497.     X.NH 1
  498.     XLimits
  499.     X.L= sec 1 limits
  500.     X.PP
  501.     X.I Lbl
  502.     Ximposes no limit on the size of text to be processed, but (like
  503.     X.I refer )
  504.     Xneeds to act on a text as a whole, rather than processing individual
  505.     Xfiles.
  506.     XThe limit on the number of levels of header is unlikely to prove a problem.
  507.     XThe number of labels which may be used is limited only by the amount
  508.     Xof memory available to a process; even on a small machine it is
  509.     Xpossible to handle a few hundred label definitions.
  510.     X.NH 1
  511.     XFurther Examples
  512.     X.L= sec 1 examples
  513.     X.PP
  514.     XThe copying of the definition macros makes it possible to use them
  515.     Xas
  516.     X.I troff
  517.     Xmacros, as in the following example:
  518.     X.DS
  519.     X\&.de L=
  520.     X\&.ie '\e\e$1'sec' .NH \e\e$2
  521.     X\&.el .ie '\e\e$1'table' .if !'\e\e$3'*' \e{
  522.     X\&.DS C
  523.     X\&Table '\e\e$3' about here
  524.     X\&.DE
  525.     X\&\e}
  526.     X\&.el .if '\e\e$1'fig' .if !'\e\e$3'*' \e{
  527.     X\&.DS C
  528.     X\&Figure '\e\e$3' about here
  529.     X\&.DE
  530.     X\&\e}
  531.     X\&..
  532.     X\&.nr LL 5i
  533.     X\&.ND
  534.     X\&.TL
  535.     X\&Example of LBL
  536.     X\&.L= sec 1 intro
  537.     X\&Introduction
  538.     X\&.L= table 1 *
  539.     X\&.PP
  540.     X\&We begin with a small table (Table @table opening@).
  541.     X\&.L= table 2 opening
  542.     X\&and consider things in more detail in Section
  543.     X\&@sec cont@.
  544.     X\&.L= sec 1 cont
  545.     X\&Continuation
  546.     X\&.L= table 1 *
  547.     X\&.PP
  548.     X\&In this continuation we refer back to Section
  549.     X\&@sec intro@, which contained
  550.     X\&Table @table opening@, and present more detailed
  551.     X\&information in Table
  552.     X\&@table detail@.
  553.     X\&.L= table 2 detail
  554.     X\&.L= sec 2 subcont
  555.     X\&Sub-continuation
  556.     X\&.PP
  557.     X\&In which we further refine things, as shown in
  558.     X\&Table @table mega-detail@ below.
  559.     X\&.L= table 2 mega-detail
  560.     X.DE
  561.     XIn the above, the ``.L=\ sec'' macros automatically generate the
  562.     Xnumbered headings by expanding to the \fIms\fR ``.NH'' macros,
  563.     Xwhile the ``table'' definitions cause the insertion of figures
  564.     Xsuch as
  565.     X.DS C
  566.     XTable 'detail' about here
  567.     X.DE
  568.     XThe above example thus produces the following:
  569.     X.DS
  570.     X                  Example of LBL
  571.     X
  572.     X
  573.     X
  574.     X
  575.     X
  576.     X\fI1.  Introduction\fR
  577.     X
  578.     X     We begin with a small table (Table 1.1).
  579.     X
  580.     X
  581.     X            Table 'opening' about here
  582.     X
  583.     X and consider things in more detail in Section 2.
  584.     X
  585.     X\fI2.  Continuation\fR
  586.     X
  587.     X     In this continuation we refer back to Section
  588.     X1,  which  contained  Table  1.1, and present more
  589.     Xdetailed information in Table 2.1.
  590.     X
  591.     X
  592.     X            Table 'detail' about here
  593.     X
  594.     X
  595.     X
  596.     X\fI2.1.  Sub-continuation\fR
  597.     X
  598.     X     In which we further refine things,  as  shown
  599.     Xin Table 2.2 below.
  600.     X
  601.     X
  602.     X          Table 'mega-detail' about here
  603.     X.DE
  604.     X.PP
  605.     XThe alphabetic formats may be useful for such things as appendices,
  606.     Xe.g.
  607.     X.DS
  608.     X\&.L= format appendix %A
  609.     X\&.L= appendix 1 trade-marks
  610.     X\&.SH
  611.     X\&Appendix @appendix trade-marks@:
  612.     X\&List of Registered Trade Marks
  613.     X\&.LP
  614.     X\&(For the addresses of the proprietors see
  615.     X\&@appendix props@).
  616.     X\&  ...
  617.     X\&.L= appendix 1 props
  618.     X.DE
  619.     Xwhich will generate
  620.     X.DS
  621.     X\fIAppendix A: List of Registered Trade Marks\fR
  622.     X
  623.     X(For the addresses of the proprietors see appendix B).
  624.     X.DE
  625. SHAR_EOF
  626. if test 9613 -ne "`wc -c < 'lbl'`"
  627. then
  628.     echo shar: "error transmitting 'lbl'" '(should have been 9613 characters)'
  629. fi
  630. fi
  631. echo shar: "extracting 'lbl.1'" '(5623 characters)'
  632. if test -f 'lbl.1'
  633. then
  634.     echo shar: "will not over-write existing file 'lbl.1'"
  635. else
  636. sed 's/^    X//' << \SHAR_EOF > 'lbl.1'
  637.     X.\" (C) C.D.F. Miller, Heriot-Watt University, March 1984
  638.     X.\"
  639.     X.TH LBL 1 Local
  640.     X.ad
  641.     X.fi
  642.     X.SH NAME
  643.     Xlbl \- preprocess symbolic labels for troff(1) text
  644.     X.SH SYNOPSIS
  645.     X.B lbl
  646.     X[
  647.     X.B -d\c
  648.     Xdelim
  649.     X] [
  650.     X.B -m\c
  651.     Xmacro
  652.     X] [
  653.     X.B -l
  654.     X] [
  655.     X.B -s
  656.     X] [ file ... ]
  657.     X.SH DESCRIPTION
  658.     X.I Lbl
  659.     Xis a preprocessor for
  660.     X.I troff (1)
  661.     Xwhich constructs serial numbers automatically for tables, equations,
  662.     Xsections, etc., and allows them to be referred to by symbolic names.
  663.     XIt avoids the need for a user to keep track of such numberings, and
  664.     Xto alter all cross-references whenever a labelled
  665.     Xobject is introduced or deleted.
  666.     X.PP
  667.     XAs many independent sequences of labels as required can be maintained;
  668.     Xeach sequence is given a symbolic name, known as the
  669.     X.I label-type .
  670.     XWithin each label-type, objects are referred to by symbolic names known
  671.     Xas
  672.     X.I labels ;
  673.     Xthe same label may be used in several different label-types without problems.
  674.     XNames for labels and label-types may be arbitrary sequences of alphanumeric
  675.     Xcharacters.
  676.     XIn addition, the special label-name ``*'' may be used as an anonymous label,
  677.     Xused to increment a level counter without generating a label (e.g. to keep
  678.     Xtable numbers in step with the corresponding section numbers).
  679.     X.PP
  680.     X.I Lbl
  681.     Xreads as input the concatenation of all specified
  682.     X.I file
  683.     Xarguments (interpreting ``-'' to mean the standard input);
  684.     Xif no
  685.     X.I file
  686.     Xargument is given,
  687.     X.I lbl
  688.     Xreads the standard input.
  689.     XThe input consists of arbitrary text (normally input for
  690.     X.I troff (1),
  691.     X.I eqn (1),
  692.     Xand the rest of that family) interspersed with
  693.     X.I label-definitions
  694.     Xand
  695.     X.I label-references ,
  696.     Xtogether with a few other sorts of definition described below.
  697.     X.PP
  698.     X\fILabel Definitions:\fR
  699.     Xa label-definition
  700.     Xdefines the value of a symbolic label.
  701.     XAll such definitions are introduced by a line beginning with
  702.     Xa special
  703.     X.I troff
  704.     Xmacro; the default macro is
  705.     X.B \&.L=
  706.     Xbut this can be overridden in the command line.
  707.     XThe label-definition macro is followed by a label-type, a numeric level,
  708.     Xand a label-name;
  709.     Xa value is given to the label by incrementing the current count for
  710.     Xthe label-type at the given level (similar to the generation of
  711.     Xnumbered headings by such macros as
  712.     X.B \&.NH
  713.     Xin the
  714.     X.I ms (6)
  715.     Xpackage,
  716.     X.B \&.H
  717.     Xin
  718.     X.I mm
  719.     Xand
  720.     X.B \&.sh
  721.     Xin
  722.     X.I me ).
  723.     XUnless otherwise specified, the first count generated at a given level will
  724.     Xbe 1; when a count is incremented, all deeper counts are reset to 0.
  725.     X.PP
  726.     XThere are several other uses of the definition-macro:
  727.     X.IP "\&.L= delimiter off"
  728.     X.br
  729.     Xinhibits all subsequent translation of label-references;
  730.     X.IP "\&.L= delimiter \fIchar\fR"
  731.     X.br
  732.     Xresets the delimiter introducing label-references to
  733.     X.I char
  734.     X(see below);
  735.     X.IP "\&.L= format \fIlabel-type pattern\fR"
  736.     Xresets the printing format for a label reference (see below);
  737.     X.IP "\&.L= last \fIlabel-type count ...\fR"
  738.     Xresets the counts for \fIlabel-type\fR as though the last label generated
  739.     Xhad had the specified counts for its successive levels (missing counts
  740.     Xall being taken as 0).
  741.     XAll counts must be arabic numerals, regardless of the print format being
  742.     Xused for the label-type.
  743.     X.LP
  744.     XAll label-definition, etc., lines are copied unchanged to the output.
  745.     X.PP
  746.     X\fILabel References\fR:
  747.     Xa label-reference is introduced and terminated by a
  748.     X.I delimiter
  749.     Xcharacter (default ``@'');
  750.     Xthe opening delimiter is followed by a label-type and a label-name;
  751.     Xthe entire reference is replaced by the value of the specified label,
  752.     Xprinted according to the format specified for the label-type (see below).
  753.     X.PP
  754.     X\fIPrint Formats\fR:
  755.     Xa print format consists of a literal string containing escape-sequences
  756.     Xfor which successive values of the level counts of a label are substituted.
  757.     XThe format is copied only as far as the escape sequence for the last level
  758.     Xof the label being printed, and it is an error for there to be too few
  759.     Xescape sequences.
  760.     XThe sequences are
  761.     X.IP %1
  762.     Xprint in arabic numerals, no non-significant leading zeros;
  763.     X.IP %0
  764.     Xprint as for ``%1'', but subtracting 1 so that counts start from 0 rather than
  765.     X1.
  766.     X.IP %i
  767.     Xprint in lower-case roman numerals;
  768.     X.IP %I
  769.     Xprint in upper-case roman;
  770.     X.IP %a
  771.     Xprint as a lower-case letter (starting at ``a'');
  772.     X.IP %A
  773.     Xprint as an upper-case letter.
  774.     X``%'' followed by any other character prints as that character.
  775.     X.LP
  776.     XThe default format is to print all levels in arabic, separated by periods
  777.     X(i.e. "%1.%1.%1.%1\ ...").
  778.     X.PP
  779.     X\fICommand Line Options\fR:
  780.     X.IP -d\fIdelim\fR
  781.     X.br
  782.     X.I delim
  783.     Xis a single character to be used in place of ``@''
  784.     Xas the label-reference delimiter.
  785.     X.IP -m\fImacro\fR
  786.     X.br
  787.     X.I macro
  788.     Xis a 2-character macro-name to be used in place of ``.L='' as the
  789.     Xlabel-definition macro.
  790.     X.IP -l
  791.     Xcauses a listing of all label-definitions to be written to the standard
  792.     Xerror stream.
  793.     X.IP -s
  794.     Xsuppresses all output except error messages and the listing generated by
  795.     Xthe \fI-l\fR option, which is automatically turned on.
  796.     X.SH EXAMPLE
  797.     X Input
  798.     X   .L= sec 1 intro
  799.     X   .L= format sec %A.%1.%1.%1.%1
  800.     X   .L= last table 3 1
  801.     X   This is Section @sec intro@; it is followed by Section
  802.     X   @sec next@ which contains Section @sec subsection@.
  803.     X   .L= table 2 only.
  804.     X   The only table used is Table @table only@.
  805.     X   .L= sec 1 next
  806.     X   .L= sec 2 subsection
  807.     X Output
  808.     X   .L= sec 1 intro
  809.     X   .L= format sec %A.%1.%1.%1.%1
  810.     X   .L= last table 3 1
  811.     X   This is Section A; it is followed by Section
  812.     X   B which contains Section B.1.
  813.     X   .L= table 2 only.
  814.     X   The only table used is Table 3.2.
  815.     X   .L= sec 1 next
  816.     X   .L= sec 2 subsection
  817.     X.SH BUGS
  818.     XWith the
  819.     X.I -s
  820.     Xoption, errors such as reference to an undefined label, which can only
  821.     Xbe detected on a second scan of the input, are not reported.
  822.     X.SH FILES
  823.     X/tmp/lbl* - temporary storage
  824.     X.SH "SEE ALSO"
  825.     Xtroff(1), nroff(1), eqn(1), refer(1), tbl(1)
  826. SHAR_EOF
  827. if test 5623 -ne "`wc -c < 'lbl.1'`"
  828. then
  829.     echo shar: "error transmitting 'lbl.1'" '(should have been 5623 characters)'
  830. fi
  831. fi
  832. echo shar: "extracting 'lbl.doc'" '(10768 characters)'
  833. if test -f 'lbl.doc'
  834. then
  835.     echo shar: "will not over-write existing file 'lbl.doc'"
  836. else
  837. sed 's/^    X//' << \SHAR_EOF > 'lbl.doc'
  838.     X
  839.     X
  840.     X
  841.     X
  842.     X
  843.     X
  844.     X
  845.     X
  846.     X
  847.     X          LBL - Symbolic Labels in Text Documents
  848.     X
  849.     X
  850.     X
  851.     X
  852.     X
  853.     X1.  Introduction
  854.     X
  855.     X     _l_b_l is a pre-processor for _t_r_o_f_f and _n_r_o_f_f which allows
  856.     XSections,  Figures,  Tables,  etc.,  to  be  referred  to by
  857.     Xsymbolic names rather than  by  absolute  number.   It  will
  858.     Xhandle forward references as well as backward ones.
  859.     X
  860.     X     Uses of  a  label  in  the  text  are  indicated  by  a
  861.     Xdelimiter  character (default '@', but resettable), followed
  862.     Xby a _t_y_p_e name (e.g. "TABLE", "EQN", etc.), followed by  the
  863.     Xlabel itself (e.g. "Profits-1983").  Each such occurrence is
  864.     Xreplaced  by  a  reference  number;  the  default  style  of
  865.     Xnumbering  is  a sequence of period-separated arabic numbers
  866.     X(e.g. 2.4.1)  but  this  is  resettable.   Finally,  another
  867.     Xdelimiter is required to close the reference (cf. the use of
  868.     Xdelimiters in _e_q_n for in-line equations).
  869.     X
  870.     XExamples:
  871.     X
  872.     X        For full details refer to Table @TABLE Profits-1983@.
  873.     X        As we saw in Chapter @chap intro@, ...
  874.     X        Figure @fig wing-profile@ shows the airflow patterns ...
  875.     X
  876.     X
  877.     X     Labels may be defined at any point in  the  text.   The
  878.     Xdefinition looks like a _t_r_o_f_f macro, and the definition line
  879.     Xis retained in the original text.   By  default,  the  macro
  880.     Xused  is  ".L=",  but  this can be reset.  The macro takes 3
  881.     Xarguments: a type-name, a level-number, and a label-name.
  882.     X
  883.     X     The type-name corresponds to  that  used  to  signal  a
  884.     Xlabel  occurrence  in  the text.  There is no restriction on
  885.     Xthe choice of name; any sequence of non-blank characters may
  886.     Xbe used.  Upper- and lower-case letters _a_r_e distinguished.
  887.     X
  888.     X     The  level-number  corresponds  to   the   header-level
  889.     Xnumbers  used  by  the .NH macro in _m_s, the .sh macro in _m_e,
  890.     Xetc.  The index at the given level is incremented by 1,  and
  891.     Xall higher indexes set to 0.  Initially, all indexes are set
  892.     Xto 0 by default, but other starting values  may  be  chosen.
  893.     XThere is an implementation-defined restriction on the number
  894.     Xof levels of index (currently 20);  it  is  not  anticipated
  895.     Xthat this will lead to problems.
  896.     X
  897.     X     The label may be any sequence of non-blank  characters;
  898.     X
  899.     X
  900.     X
  901.     X
  902.     X
  903.     X
  904.     X
  905.     X
  906.     X
  907.     X                           - 2 -
  908.     X
  909.     X
  910.     Xthe   same  label  may  be  used  in  more  than  one  type.
  911.     XFurthermore, the special label-name ``*''  can  be  used  to
  912.     Xincrement  the  appropriate level-counter without defining a
  913.     Xlabel at all; this is useful, for example, when all  tables,
  914.     Xfigures,  etc.,  in  a section take their initial index from
  915.     Xthe section number: two ways of doing this would be:
  916.     X
  917.     Xa.
  918.     X    .L= section 1 this-section
  919.     X    .L= last table 0
  920.     X    .L= last figure 0
  921.     X    ...
  922.     X    ... refer to table @section this-section@.@table profits@ ...
  923.     X    ... see figure @section this-section@.@figure structure@ ...
  924.     X    ...
  925.     X    .L= table 1 profits
  926.     X    ...
  927.     X    .L= figure 1 structure
  928.     X    ...
  929.     X
  930.     X(see section 3 for the use of
  931.     X``.L= last ...'')
  932.     X
  933.     Xb.
  934.     X    .L= section 1 this-section
  935.     X    .L= table 1 *
  936.     X    .L= figure 1 *
  937.     X    ...
  938.     X    ... refer to table @table profits@ ...
  939.     X    ... see figure @figure structure@ ...
  940.     X    ...
  941.     X    .L= table 2 profits
  942.     X    ...
  943.     X    .L= figure 2 structure
  944.     X    ...
  945.     X
  946.     XIt is largely a matter of taste which technique is used; the
  947.     Xformer  is more long-winded, but avoids the need to remember
  948.     Xto keep the tables  and  figures  in  step  every  time  the
  949.     Xsection is updated.  Yet a third possibility (similar to the
  950.     Xfirst) would be:
  951.     X
  952.     Xc.
  953.     X    .L= section 1 this-section
  954.     X    .ds Sc "@section this-section@
  955.     X    .L= last table 0
  956.     X    ...
  957.     X    ... refer to table .@table profits@
  958.     X    etc.
  959.     X
  960.     Xmaking use of the string-definition facility within _n_r_o_f_f.
  961.     X
  962.     X     It is important to be  aware  that  all  processing  on
  963.     Xlabels  is done before _t_r_o_f_f processes the text; attempts to
  964.     X
  965.     X
  966.     X
  967.     X
  968.     X
  969.     X
  970.     X
  971.     X
  972.     X
  973.     X                           - 3 -
  974.     X
  975.     X
  976.     Xbuild label-references by  using  macros  or  _t_r_o_f_f  strings
  977.     Xregisters will almost certainly not work as expected.
  978.     X
  979.     X2.  Command Line Options
  980.     X
  981.     X     Options to _l_b_l are set in the command line,  which  has
  982.     Xthe form
  983.     X
  984.     X        lbl [ -d_d_e_l_i_m ] [ -m_m_a_c_r_o ] [ -l ] [ -s ]
  985.     X
  986.     X
  987.     X-d   _d_e_l_i_m  is  the  character  used  to   delimit   in-line
  988.     X     occurrences of label references (default ``@'');
  989.     X
  990.     X-m   _m_a_c_r_o is the 2-character name of a  _t_r_o_f_f  macro  which
  991.     X     introduces label definitions, etc. (default ``L='');
  992.     X
  993.     X-l   causes a listing of label-definitions to be written  to
  994.     X     the  standard error stream.  Each label-type is listed,
  995.     X     together with its print format, followed by a line  for
  996.     X     each  label  of that type, showing label-name, file and
  997.     X     line where it is defined, and value;
  998.     X
  999.     X-s   causes the generation of the _t_r_o_f_f  input  file  to  be
  1000.     X     suppressed; setting -_s automatically also sets -_l.
  1001.     X
  1002.     X3.  Control directives
  1003.     X
  1004.     X     In addition to defining labels, the .L= macro  (or  its
  1005.     Xsubstitute)  can  be used for several other purposes.  These
  1006.     Xare all indicated by commands of the form
  1007.     X
  1008.     X        .L= _c_o_m_m_a_n_d _a_r_g_u_m_e_n_t ...
  1009.     X
  1010.     Xwhere the _c_o_m_m_a_n_ds are reserved words which may not be  used
  1011.     Xas  type-names.   These  commands  allow  control  over  the
  1012.     Xinitialisation of label values, the print format of  labels,
  1013.     Xand thelabel reference delimiter.
  1014.     X
  1015.     X.L= delimiter off
  1016.     X     turns off interpretation  of  the  delimiter  character
  1017.     X     altogether;  subsequent  text is copied literally until
  1018.     X     another _d_e_l_i_m_i_t_e_r command is encountered;
  1019.     X
  1020.     X.L= delimiter _c_h_a_r_a_c_t_e_r
  1021.     X     resets the delimiter in subsequent text  to  the  given
  1022.     X     character;
  1023.     X
  1024.     X.L= format _t_y_p_e_n_a_m_e _s_t_r_i_n_g
  1025.     X     sets the print format for labels of the  given  type  -
  1026.     X     see section 3.1;
  1027.     X
  1028.     X.L= last _t_y_p_e_n_a_m_e _c_o_u_n_t_1 _c_o_u_n_t_2 ...
  1029.     X     resets the counters for _t_y_p_e_n_a_m_e  as  though  the  last
  1030.     X
  1031.     X
  1032.     X
  1033.     X
  1034.     X
  1035.     X
  1036.     X
  1037.     X
  1038.     X
  1039.     X                           - 4 -
  1040.     X
  1041.     X
  1042.     X     label  generated  had  been  _c_o_u_n_t_1._c_o_u_n_t_2... (with all
  1043.     X     omitted counts taken as 0).
  1044.     X
  1045.     X3.1.  Print formats
  1046.     X
  1047.     X     The default print format for a label is as  a  sequence
  1048.     Xof  period-separated  arabic  numerals.  However, it is also
  1049.     Xpossible  to  specify  alphabetic  or  roman  labels,  or  a
  1050.     Xmixture,  and  to have separators other than a period.  This
  1051.     Xis governed by the format given in a ``.LE format'' command.
  1052.     X
  1053.     X     Such a format contains escape sequences (flagged  by  a
  1054.     X``%'' character) and literal text.  The text is copied until
  1055.     Xan escape  sequence  is  encountered;  such  a  sequence  is
  1056.     Xreplaced by the index for the next level of the label value,
  1057.     Xprinted in one of the following formats:
  1058.     X
  1059.     X%1   Arabic  numerals   (without   non-significant   leading
  1060.     X     zeros);
  1061.     X
  1062.     X%0   As %1, but offset by 1 so that the first value  printed
  1063.     X     will be 0 rather than 1;
  1064.     X
  1065.     X%a   Lower-case alphabetics, starting  at  ``a'';  ``z''  is
  1066.     X     followed by ``aa'', etc.;
  1067.     X
  1068.     X%A   Upper-case alphabetics;
  1069.     X
  1070.     X%i   Lower-case roman numerals (with some  odd  choices  for
  1071.     X     large  numbers,  consistent  with  the  roman  numerals
  1072.     X     printed by _t_r_o_f_f).
  1073.     X
  1074.     X%I   Upper-case roman numerals.
  1075.     X
  1076.     XA ``%'' followed  by  any  other  character  (in  particular
  1077.     Xanother ``%'') prints as that character.
  1078.     X
  1079.     X4.  Limits
  1080.     X
  1081.     X     _L_b_l imposes  no  limit  on  the  size  of  text  to  be
  1082.     Xprocessed,  but  (like  _r_e_f_e_r)  needs  to act on a text as a
  1083.     Xwhole, rather than processing individual files.   The  limit
  1084.     Xon  the  number  of  levels of header is unlikely to prove a
  1085.     Xproblem.  The number of labels which may be used is  limited
  1086.     Xonly by the amount of memory available to a process; even on
  1087.     Xa small machine it is possible to handle a few hundred label
  1088.     Xdefinitions.
  1089.     X
  1090.     X5.  Further Examples
  1091.     X
  1092.     X     The copying of the definition macros makes it  possible
  1093.     Xto use them as _t_r_o_f_f macros, as in the following example:
  1094.     X
  1095.     X
  1096.     X
  1097.     X
  1098.     X
  1099.     X
  1100.     X
  1101.     X
  1102.     X
  1103.     X
  1104.     X
  1105.     X                           - 5 -
  1106.     X
  1107.     X
  1108.     X
  1109.     X        .de L=
  1110.     X        .ie '\\$1'sec' .NH \\$2
  1111.     X        .el .ie '\\$1'table' .if !'\\$3'*' \{
  1112.     X        .DS C
  1113.     X        Table '\\$3' about here
  1114.     X        .DE
  1115.     X        \}
  1116.     X        .el .if '\\$1'fig' .if !'\\$3'*' \{
  1117.     X        .DS C
  1118.     X        Figure '\\$3' about here
  1119.     X        .DE
  1120.     X        \}
  1121.     X        ..
  1122.     X        .nr LL 5i
  1123.     X        .ND
  1124.     X        .TL
  1125.     X        Example of LBL
  1126.     X        .L= sec 1 intro
  1127.     X        Introduction
  1128.     X        .L= table 1 *
  1129.     X        .PP
  1130.     X        We begin with a small table (Table @table opening@).
  1131.     X        .L= table 2 opening
  1132.     X        and consider things in more detail in Section
  1133.     X        @sec cont@.
  1134.     X        .L= sec 1 cont
  1135.     X        Continuation
  1136.     X        .L= table 1 *
  1137.     X        .PP
  1138.     X        In this continuation we refer back to Section
  1139.     X        @sec intro@, which contained
  1140.     X        Table @table opening@, and present more detailed
  1141.     X        information in Table
  1142.     X        @table detail@.
  1143.     X        .L= table 2 detail
  1144.     X        .L= sec 2 subcont
  1145.     X        Sub-continuation
  1146.     X        .PP
  1147.     X        In which we further refine things, as shown in
  1148.     X        Table @table mega-detail@ below.
  1149.     X        .L= table 2 mega-detail
  1150.     X
  1151.     XIn the above, the ``.L= sec'' macros automatically  generate
  1152.     Xthe numbered headings by expanding to the _m_s ``.NH'' macros,
  1153.     Xwhile the  ``table''  definitions  cause  the  insertion  of
  1154.     Xfigures such as
  1155.     X
  1156.     X                 Table 'detail' about here
  1157.     X
  1158.     XThe above example thus produces the following:
  1159.     X
  1160.     X
  1161.     X
  1162.     X
  1163.     X
  1164.     X
  1165.     X
  1166.     X
  1167.     X
  1168.     X
  1169.     X
  1170.     X
  1171.     X                           - 6 -
  1172.     X
  1173.     X
  1174.     X
  1175.     X                          Example of LBL
  1176.     X
  1177.     X
  1178.     X
  1179.     X
  1180.     X
  1181.     X        _1.  _I_n_t_r_o_d_u_c_t_i_o_n
  1182.     X
  1183.     X             We begin with a small table (Table 1.1).
  1184.     X
  1185.     X
  1186.     X                    Table 'opening' about here
  1187.     X
  1188.     X         and consider things in more detail in Section 2.
  1189.     X
  1190.     X        _2.  _C_o_n_t_i_n_u_a_t_i_o_n
  1191.     X
  1192.     X             In this continuation we refer back to Section
  1193.     X        1,  which  contained  Table  1.1, and present more
  1194.     X        detailed information in Table 2.1.
  1195.     X
  1196.     X
  1197.     X                    Table 'detail' about here
  1198.     X
  1199.     X
  1200.     X
  1201.     X        _2._1.  _S_u_b-_c_o_n_t_i_n_u_a_t_i_o_n
  1202.     X
  1203.     X             In which we further refine things,  as  shown
  1204.     X        in Table 2.2 below.
  1205.     X
  1206.     X
  1207.     X                  Table 'mega-detail' about here
  1208.     X
  1209.     X
  1210.     X     The alphabetic formats may be useful for such things as
  1211.     Xappendices, e.g.
  1212.     X
  1213.     X        .L= format appendix %A
  1214.     X        .L= appendix 1 trade-marks
  1215.     X        .SH
  1216.     X        Appendix @appendix trade-marks@:
  1217.     X        List of Registered Trade Marks
  1218.     X        .LP
  1219.     X        (For the addresses of the proprietors see
  1220.     X        @appendix props@).
  1221.     X          ...
  1222.     X        .L= appendix 1 props
  1223.     X
  1224.     Xwhich will generate
  1225.     X
  1226.     X
  1227.     X
  1228.     X
  1229.     X
  1230.     X
  1231.     X
  1232.     X
  1233.     X
  1234.     X
  1235.     X
  1236.     X
  1237.     X                           - 7 -
  1238.     X
  1239.     X
  1240.     X
  1241.     X        _A_p_p_e_n_d_i_x _A: _L_i_s_t _o_f _R_e_g_i_s_t_e_r_e_d _T_r_a_d_e _M_a_r_k_s
  1242.     X
  1243.     X        (For the addresses of the proprietors see appendix B).
  1244.     X
  1245.     X
  1246.     X
  1247.     X
  1248.     X
  1249.     X
  1250.     X
  1251.     X
  1252.     X
  1253.     X
  1254.     X
  1255.     X
  1256.     X
  1257.     X
  1258.     X
  1259.     X
  1260.     X
  1261.     X
  1262.     X
  1263.     X
  1264.     X
  1265.     X
  1266.     X
  1267.     X
  1268.     X
  1269.     X
  1270.     X
  1271.     X
  1272.     X
  1273.     X
  1274.     X
  1275.     X
  1276.     X
  1277.     X
  1278.     X
  1279.     X
  1280.     X
  1281.     X
  1282.     X
  1283.     X
  1284.     X
  1285.     X
  1286.     X
  1287.     X
  1288.     X
  1289.     X
  1290.     X
  1291.     X
  1292.     X
  1293.     X
  1294.     X
  1295.     X
  1296.     X
  1297.     X
  1298.     X
  1299.     X
  1300. echo shar: "274 control characters may be missing from 'lbl.doc'"
  1301. SHAR_EOF
  1302. if test 10768 -ne "`wc -c < 'lbl.doc'`"
  1303. then
  1304.     echo shar: "error transmitting 'lbl.doc'" '(should have been 10768 characters)'
  1305. fi
  1306. fi
  1307. echo shar: "done with directory 'doc'"
  1308. cd ..
  1309. if test ! -d 'hdr'
  1310. then
  1311.     echo shar: "creating directory 'hdr'"
  1312.     mkdir 'hdr'
  1313. fi
  1314. echo shar: "entering directory 'hdr'"
  1315. cd 'hdr'
  1316. echo shar: "extracting 'ftypes.h'" '(426 characters)'
  1317. if test -f 'ftypes.h'
  1318. then
  1319.     echo shar: "will not over-write existing file 'ftypes.h'"
  1320. else
  1321. sed 's/^    X//' << \SHAR_EOF > 'ftypes.h'
  1322.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1323.     X *
  1324.     X *    Permission is hereby given to reproduce or modify this
  1325.     X *    software freely, provided that this notice be retained,
  1326.     X *    and that no use be made of the software for commercial
  1327.     X *    purposes without the express written permission of the
  1328.     X *    author.
  1329.     X */
  1330.     X
  1331.     Xchar    *copy();
  1332.     Xlabel    *findlabel();
  1333.     Xtype    *addtype();
  1334.     Xtype    *findtype();
  1335.     X
  1336.     Xchar    *fgets();
  1337.     Xchar    *malloc();
  1338.     Xchar    *mktemp();
  1339. SHAR_EOF
  1340. if test 426 -ne "`wc -c < 'ftypes.h'`"
  1341. then
  1342.     echo shar: "error transmitting 'ftypes.h'" '(should have been 426 characters)'
  1343. fi
  1344. fi
  1345. echo shar: "extracting 'lbl.h'" '(528 characters)'
  1346. if test -f 'lbl.h'
  1347. then
  1348.     echo shar: "will not over-write existing file 'lbl.h'"
  1349. else
  1350. sed 's/^    X//' << \SHAR_EOF > 'lbl.h'
  1351.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1352.     X *
  1353.     X *    Permission is hereby given to reproduce or modify this
  1354.     X *    software freely, provided that this notice be retained,
  1355.     X *    and that no use be made of the software for commercial
  1356.     X *    purposes without the express written permission of the
  1357.     X *    author.
  1358.     X */
  1359.     X
  1360.     X#include    <stdio.h>
  1361.     X#include    <types.h>
  1362.     X#include    <ftypes.h>
  1363.     X
  1364.     X#define    STDFORM    "%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1.%1"
  1365.     X
  1366.     X#define    MAGIC1    '\01'
  1367.     X#define MAGIC2    '\02'
  1368.     X#define M_FILE    'F'
  1369.     X#define M_DELIM    'D'
  1370. SHAR_EOF
  1371. if test 528 -ne "`wc -c < 'lbl.h'`"
  1372. then
  1373.     echo shar: "error transmitting 'lbl.h'" '(should have been 528 characters)'
  1374. fi
  1375. fi
  1376. echo shar: "extracting 'types.h'" '(1122 characters)'
  1377. if test -f 'types.h'
  1378. then
  1379.     echo shar: "will not over-write existing file 'types.h'"
  1380. else
  1381. sed 's/^    X//' << \SHAR_EOF > 'types.h'
  1382.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1383.     X *
  1384.     X *    Permission is hereby given to reproduce or modify this
  1385.     X *    software freely, provided that this notice be retained,
  1386.     X *    and that no use be made of the software for commercial
  1387.     X *    purposes without the express written permission of the
  1388.     X *    author.
  1389.     X */
  1390.     X
  1391.     X#define    rg        register
  1392.     X#define    us        unsigned
  1393.     X
  1394.     X/*** Header levels ***/
  1395.     X#define    NLEVELS    20
  1396.     Xtypedef    us int            levels[NLEVELS];
  1397.     X
  1398.     X/*** Header format ***/
  1399.     Xtypedef    char            *format;
  1400.     X
  1401.     X/*** Label type: name and current header levels ***/
  1402.     Xtypedef struct type
  1403.     X{
  1404.     X    char        *t_name;
  1405.     X    levels        t_levels;
  1406.     X    format        t_format;
  1407.     X    struct label    *t_labels;
  1408.     X    struct type    *t_next;
  1409.     X}                type;
  1410.     X
  1411.     X/*** Label definition ***/
  1412.     Xtypedef struct label
  1413.     X{
  1414.     X    char        *l_name;
  1415.     X    type        *l_type;
  1416.     X    levels        l_levels;
  1417.     X    us int        l_bottom;        /* Last significant level */
  1418.     X    char        *l_file;        /* File where defined */
  1419.     X    long        l_line;            /* line   "      "    */
  1420.     X    struct label    *l_next;
  1421.     X}                label;
  1422.     X
  1423.     X/*** Action routine ***/
  1424.     Xtypedef int            (*func)();
  1425.     X
  1426.     X/*** Command keyword ***/
  1427.     Xtypedef struct keyword
  1428.     X{
  1429.     X    char    *k_name;
  1430.     X    func    k_action;
  1431.     X    us int    k_minargs;
  1432.     X    us int    k_maxargs;
  1433.     X}                keyword;
  1434. SHAR_EOF
  1435. if test 1122 -ne "`wc -c < 'types.h'`"
  1436. then
  1437.     echo shar: "error transmitting 'types.h'" '(should have been 1122 characters)'
  1438. fi
  1439. fi
  1440. echo shar: "done with directory 'hdr'"
  1441. cd ..
  1442. if test ! -d 'src'
  1443. then
  1444.     echo shar: "creating directory 'src'"
  1445.     mkdir 'src'
  1446. fi
  1447. echo shar: "entering directory 'src'"
  1448. cd 'src'
  1449. echo shar: "extracting 'Makefile'" '(446 characters)'
  1450. if test -f 'Makefile'
  1451. then
  1452.     echo shar: "will not over-write existing file 'Makefile'"
  1453. else
  1454. sed 's/^    X//' << \SHAR_EOF > 'Makefile'
  1455.     XOBJS=lbl.o actions.o build.o error.o externs.o find.o keyword.o list.o printl.o rescan.o scan.o signals.o
  1456.     XSRCS=lbl.c actions.c build.c error.c externs.c find.c keyword.c list.c printl.c rescan.c scan.c signals.c
  1457.     XHDR=../hdr
  1458.     X
  1459.     XCFLAGS=-O -I$(HDR)
  1460.     XLDFLAGS=-i
  1461.     X
  1462.     Xlbl:    $(OBJS)
  1463.     X    cc -o lbl $(LDFLAGS) $(OBJS)
  1464.     X
  1465.     Xlint:    $(SRCS)
  1466.     X    lint -abchx $(SRCS)
  1467.     X
  1468.     Xtags:    $(SRCS)
  1469.     X    ctags $(SRCS)
  1470.     X
  1471.     Xclean:
  1472.     X    rm -f *.o tags lbl
  1473.     X
  1474.     X$(OBJS): $(HDR)/lbl.h $(HDR)/types.h $(HDR)/ftypes.h
  1475. SHAR_EOF
  1476. if test 446 -ne "`wc -c < 'Makefile'`"
  1477. then
  1478.     echo shar: "error transmitting 'Makefile'" '(should have been 446 characters)'
  1479. fi
  1480. fi
  1481. echo shar: "extracting 'actions.c'" '(1518 characters)'
  1482. if test -f 'actions.c'
  1483. then
  1484.     echo shar: "will not over-write existing file 'actions.c'"
  1485. else
  1486. sed 's/^    X//' << \SHAR_EOF > 'actions.c'
  1487.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1488.     X *
  1489.     X *    Permission is hereby given to reproduce or modify this
  1490.     X *    software freely, provided that this notice be retained,
  1491.     X *    and that no use be made of the software for commercial
  1492.     X *    purposes without the express written permission of the
  1493.     X *    author.
  1494.     X */
  1495.     X
  1496.     X/* actions.c:
  1497.     X *    keyword action routines
  1498.     X */
  1499.     X
  1500.     X#include    <lbl.h>
  1501.     X#include    <ctype.h>
  1502.     X
  1503.     Xextern char    *def_format;
  1504.     Xextern int    sflag;
  1505.     Xextern FILE    *tempfile;
  1506.     X
  1507.     X/*ARGSUSED*/
  1508.     Xa_delimiter(nargs, argvec)
  1509.     X    int    nargs;
  1510.     X    char    *argvec[];
  1511.     X{
  1512.     X    if (strcmp(argvec[1], "off") == 0)
  1513.     X    {
  1514.     X        if (!sflag)
  1515.     X            fprintf(tempfile, "%c%c%c\n", MAGIC1, MAGIC2, M_DELIM);
  1516.     X        return;
  1517.     X    }
  1518.     X    if (argvec[1][1] != '\0')
  1519.     X    {
  1520.     X        error("delimiter more than 1 character");
  1521.     X        return;
  1522.     X    }
  1523.     X    if (argvec[1][0] == '\0')
  1524.     X    {
  1525.     X        error("null delimiter character");
  1526.     X        return;
  1527.     X    }
  1528.     X    if (!sflag)
  1529.     X        fprintf(tempfile, "%c%c%c%c\n", MAGIC1, MAGIC2,
  1530.     X                M_DELIM, argvec[1][0]);
  1531.     X}
  1532.     X
  1533.     X/*ARGSUSED*/
  1534.     Xa_format(nargs, argvec)
  1535.     X    int    nargs;
  1536.     X    char    *argvec[];
  1537.     X{
  1538.     X    type    *tp    = findtype(argvec[1], 1);
  1539.     X
  1540.     X    if (tp->t_format != def_format)
  1541.     X        error("[warning] format for %s redefined", tp->t_name);
  1542.     X    tp->t_format = copy(argvec[2]);
  1543.     X}
  1544.     X
  1545.     X/*ARGSUSED*/
  1546.     Xa_last(nargs, argvec)
  1547.     X    int    nargs;
  1548.     X    char    *argvec[];
  1549.     X{
  1550.     X    type    *tp    = findtype(argvec[1], 1);
  1551.     X    int    indx;
  1552.     X
  1553.     X    nargs -= 2;
  1554.     X    argvec += 2;
  1555.     X    for (indx = 0; indx < nargs; indx++)
  1556.     X    {
  1557.     X        if (!isdigit(argvec[indx][0]))
  1558.     X        {
  1559.     X            error("non-numeric label index");
  1560.     X            break;
  1561.     X        }
  1562.     X        tp->t_levels[indx] = atoi(argvec[indx]);
  1563.     X    }
  1564.     X    while (indx < NLEVELS)
  1565.     X        tp->t_levels[indx++] = 0;
  1566.     X}
  1567. SHAR_EOF
  1568. if test 1518 -ne "`wc -c < 'actions.c'`"
  1569. then
  1570.     echo shar: "error transmitting 'actions.c'" '(should have been 1518 characters)'
  1571. fi
  1572. fi
  1573. echo shar: "extracting 'build.c'" '(2304 characters)'
  1574. if test -f 'build.c'
  1575. then
  1576.     echo shar: "will not over-write existing file 'build.c'"
  1577. else
  1578. sed 's/^    X//' << \SHAR_EOF > 'build.c'
  1579.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1580.     X *
  1581.     X *    Permission is hereby given to reproduce or modify this
  1582.     X *    software freely, provided that this notice be retained,
  1583.     X *    and that no use be made of the software for commercial
  1584.     X *    purposes without the express written permission of the
  1585.     X *    author.
  1586.     X */
  1587.     X
  1588.     X/* build.c:
  1589.     X *    routines to build new labels and label-types
  1590.     X */
  1591.     X
  1592.     X#include    <lbl.h>
  1593.     X#include    <ctype.h>
  1594.     X
  1595.     Xextern char    *def_format;
  1596.     Xextern char    *filename;
  1597.     Xextern long    fileline;
  1598.     Xextern type    *typetable;
  1599.     X
  1600.     Xchar *alloc(nbytes)
  1601.     X    us int    nbytes;
  1602.     X{
  1603.     X    char    *malloc();
  1604.     X    char    *ptr = malloc(nbytes);
  1605.     X
  1606.     X    if (ptr==NULL)
  1607.     X        fatal("ran out of memory space");
  1608.     X    return ptr;
  1609.     X}
  1610.     X
  1611.     Xchar *
  1612.     Xcopy(str)
  1613.     X    char    *str;
  1614.     X{
  1615.     X    char    *strcpy();
  1616.     X    us int    strlen();
  1617.     X
  1618.     X    char    *s = alloc(strlen(str)+1);
  1619.     X
  1620.     X    return strcpy(s, str);
  1621.     X}
  1622.     X
  1623.     Xaddlbl(lbltype, lbllevel, lblname)
  1624.     X    char    *lbltype;
  1625.     X    char    *lbllevel;
  1626.     X    char    *lblname;
  1627.     X{
  1628.     X    type    *tp = findtype(lbltype, 1);
  1629.     X    label    *lp;
  1630.     X    label    *last;
  1631.     X    us int    bottom;
  1632.     X    us int    indx;
  1633.     X
  1634.     X    if (!isdigit(lbllevel[0]))
  1635.     X    {
  1636.     X        error("non-numeric index level");
  1637.     X        return;
  1638.     X    }
  1639.     X    if ((bottom = atoi(lbllevel)) == 0 || bottom > NLEVELS)
  1640.     X    {
  1641.     X        error("index level must be in range 1-%u", NLEVELS);
  1642.     X        return;
  1643.     X    }
  1644.     X    bottom--;
  1645.     X
  1646.     X    ++(tp->t_levels[bottom]);
  1647.     X    for (indx = bottom+1; indx < NLEVELS; indx++)
  1648.     X        tp->t_levels[indx] = 0;
  1649.     X
  1650.     X    if (strcmp(lblname, "*") != 0)
  1651.     X    {
  1652.     X        lp = findlabel(tp, lblname);
  1653.     X
  1654.     X        if (lp != NULL)
  1655.     X        {
  1656.     X            error("redefinition of %s ignored", lblname);
  1657.     X            return;
  1658.     X        }
  1659.     X        lp = (label *) alloc(sizeof(label));
  1660.     X
  1661.     X        lp->l_name = copy(lblname);
  1662.     X        lp->l_type = tp;
  1663.     X        for (indx = 0; indx < bottom; indx++)
  1664.     X            lp->l_levels[indx] = tp->t_levels[indx];
  1665.     X        lp->l_levels[bottom] = tp->t_levels[bottom];
  1666.     X        lp->l_bottom = bottom;
  1667.     X        lp->l_file = filename;
  1668.     X        lp->l_line = fileline;
  1669.     X        lp->l_next = NULL;
  1670.     X        /* Add to end of list, so that verbose listing comes out
  1671.     X         * in order
  1672.     X         */
  1673.     X        if (tp->t_labels == NULL)
  1674.     X            tp->t_labels = lp;
  1675.     X        else
  1676.     X        {
  1677.     X            for (last = tp->t_labels; last->l_next != NULL;
  1678.     X                            last = last->l_next)
  1679.     X                ;
  1680.     X            last->l_next = lp;
  1681.     X        }
  1682.     X    }
  1683.     X}
  1684.     X
  1685.     Xtype *
  1686.     Xaddtype(name)
  1687.     X    char    *name;
  1688.     X{
  1689.     X    type        *tp = (type *) alloc(sizeof(type));
  1690.     X    us int        indx;
  1691.     X
  1692.     X    tp->t_name = copy(name);
  1693.     X    for (indx = 0; indx < NLEVELS; indx++)
  1694.     X        tp->t_levels[indx] = 0;
  1695.     X    tp->t_format = def_format;
  1696.     X    tp->t_labels = NULL;
  1697.     X    tp->t_next = typetable;
  1698.     X    typetable = tp;
  1699.     X    return tp;
  1700.     X}
  1701. SHAR_EOF
  1702. if test 2304 -ne "`wc -c < 'build.c'`"
  1703. then
  1704.     echo shar: "error transmitting 'build.c'" '(should have been 2304 characters)'
  1705. fi
  1706. fi
  1707. echo shar: "extracting 'error.c'" '(801 characters)'
  1708. if test -f 'error.c'
  1709. then
  1710.     echo shar: "will not over-write existing file 'error.c'"
  1711. else
  1712. sed 's/^    X//' << \SHAR_EOF > 'error.c'
  1713.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1714.     X *
  1715.     X *    Permission is hereby given to reproduce or modify this
  1716.     X *    software freely, provided that this notice be retained,
  1717.     X *    and that no use be made of the software for commercial
  1718.     X *    purposes without the express written permission of the
  1719.     X *    author.
  1720.     X */
  1721.     X
  1722.     X/* error.c:
  1723.     X *    report and handle errors
  1724.     X */
  1725.     X
  1726.     X#include    <lbl.h>
  1727.     X
  1728.     Xextern char    *progname;
  1729.     Xextern char    *filename;
  1730.     Xextern char    tempname[];
  1731.     Xextern long    fileline;
  1732.     X
  1733.     X/*VARARGS1*/
  1734.     Xerror(msg, arg1)
  1735.     X    char    *msg;
  1736.     X    char    *arg1;
  1737.     X{
  1738.     X    fprintf(stderr, "%s: ", progname);
  1739.     X    if (filename != NULL)
  1740.     X        fprintf(stderr, "%s, line %D - ", filename, fileline);
  1741.     X    fprintf(stderr, msg, arg1);
  1742.     X    fprintf(stderr, "\n");
  1743.     X}
  1744.     X
  1745.     X/*VARARGS1*/
  1746.     Xfatal(msg, arg1)
  1747.     X    char    *msg;
  1748.     X    char    *arg1;
  1749.     X{
  1750.     X    error(msg, arg1);
  1751.     X    unlink(tempname);
  1752.     X    exit(1);
  1753.     X}
  1754. SHAR_EOF
  1755. if test 801 -ne "`wc -c < 'error.c'`"
  1756. then
  1757.     echo shar: "error transmitting 'error.c'" '(should have been 801 characters)'
  1758. fi
  1759. fi
  1760. echo shar: "extracting 'externs.c'" '(579 characters)'
  1761. if test -f 'externs.c'
  1762. then
  1763.     echo shar: "will not over-write existing file 'externs.c'"
  1764. else
  1765. sed 's/^    X//' << \SHAR_EOF > 'externs.c'
  1766.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1767.     X *
  1768.     X *    Permission is hereby given to reproduce or modify this
  1769.     X *    software freely, provided that this notice be retained,
  1770.     X *    and that no use be made of the software for commercial
  1771.     X *    purposes without the express written permission of the
  1772.     X *    author.
  1773.     X */
  1774.     X
  1775.     X#include    <lbl.h>
  1776.     X
  1777.     Xchar    delimiter    = '@';
  1778.     Xchar    macroname[]    = "L=";
  1779.     Xchar    tempname[]    = "/tmp/lblXXXXXX";
  1780.     Xchar    *def_format    = STDFORM;
  1781.     Xchar    *progname    = "lbl";
  1782.     Xchar    *filename    = NULL;
  1783.     Xint    lflag        = 0;
  1784.     Xint    sflag        = 0;
  1785.     XFILE    *tempfile    = NULL;
  1786.     Xlong    fileline;
  1787.     Xtype    *typetable    = NULL;
  1788. SHAR_EOF
  1789. if test 579 -ne "`wc -c < 'externs.c'`"
  1790. then
  1791.     echo shar: "error transmitting 'externs.c'" '(should have been 579 characters)'
  1792. fi
  1793. fi
  1794. echo shar: "extracting 'find.c'" '(885 characters)'
  1795. if test -f 'find.c'
  1796. then
  1797.     echo shar: "will not over-write existing file 'find.c'"
  1798. else
  1799. sed 's/^    X//' << \SHAR_EOF > 'find.c'
  1800.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1801.     X *
  1802.     X *    Permission is hereby given to reproduce or modify this
  1803.     X *    software freely, provided that this notice be retained,
  1804.     X *    and that no use be made of the software for commercial
  1805.     X *    purposes without the express written permission of the
  1806.     X *    author.
  1807.     X */
  1808.     X
  1809.     X/* find.c:
  1810.     X *    routines to find a type entry and a label entry
  1811.     X */
  1812.     X
  1813.     X#include    <lbl.h>
  1814.     X
  1815.     Xextern type    *typetable;
  1816.     X
  1817.     Xtype *
  1818.     Xfindtype(name, create)
  1819.     X    rg char    *name;
  1820.     X    rg int    create;
  1821.     X{
  1822.     X    rg type    *tp;
  1823.     X
  1824.     X    for (tp = typetable; tp != NULL; tp = tp->t_next)
  1825.     X        if (strcmp(name, tp->t_name) == 0)
  1826.     X            return tp;
  1827.     X    if (create)
  1828.     X        return addtype(name);
  1829.     X    return NULL;
  1830.     X}
  1831.     X
  1832.     Xlabel *
  1833.     Xfindlabel(tp, name)
  1834.     X    rg type        *tp;
  1835.     X    rg char        *name;
  1836.     X{
  1837.     X    rg label    *lp;
  1838.     X
  1839.     X    if (tp == NULL)
  1840.     X        return NULL;
  1841.     X    for (lp = tp->t_labels; lp != NULL; lp = lp->l_next)
  1842.     X        if (strcmp(name, lp->l_name) == 0)
  1843.     X            return lp;
  1844.     X    return NULL;
  1845.     X}
  1846. SHAR_EOF
  1847. if test 885 -ne "`wc -c < 'find.c'`"
  1848. then
  1849.     echo shar: "error transmitting 'find.c'" '(should have been 885 characters)'
  1850. fi
  1851. fi
  1852. echo shar: "extracting 'keyword.c'" '(826 characters)'
  1853. if test -f 'keyword.c'
  1854. then
  1855.     echo shar: "will not over-write existing file 'keyword.c'"
  1856. else
  1857. sed 's/^    X//' << \SHAR_EOF > 'keyword.c'
  1858.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1859.     X *
  1860.     X *    Permission is hereby given to reproduce or modify this
  1861.     X *    software freely, provided that this notice be retained,
  1862.     X *    and that no use be made of the software for commercial
  1863.     X *    purposes without the express written permission of the
  1864.     X *    author.
  1865.     X */
  1866.     X
  1867.     X/* keyword.c:
  1868.     X *    look up a command keyword (by sequential search).
  1869.     X */
  1870.     X
  1871.     X#include    <lbl.h>
  1872.     X
  1873.     Xextern int    a_delimiter();
  1874.     Xextern int    a_format();
  1875.     Xextern int    a_last();
  1876.     X
  1877.     Xkeyword keytable[] =
  1878.     X{
  1879.     X    { "delimiter",    a_delimiter,    2,    2  },
  1880.     X    { "format",    a_format,    3,    3  },
  1881.     X    { "last",    a_last,        3,    22 }
  1882.     X};
  1883.     X#define NKEYS    (sizeof(keytable) / sizeof(keyword))
  1884.     X
  1885.     Xkeyword *
  1886.     Xfindkeyword(word)
  1887.     X    char    *word;
  1888.     X{
  1889.     X    int    indx;
  1890.     X
  1891.     X    for (indx=0; indx < NKEYS; indx++)
  1892.     X        if (strcmp(word, keytable[indx].k_name) == 0)
  1893.     X            return keytable+indx;
  1894.     X    return NULL;
  1895.     X}
  1896. SHAR_EOF
  1897. if test 826 -ne "`wc -c < 'keyword.c'`"
  1898. then
  1899.     echo shar: "error transmitting 'keyword.c'" '(should have been 826 characters)'
  1900. fi
  1901. fi
  1902. echo shar: "extracting 'lbl.c'" '(2926 characters)'
  1903. if test -f 'lbl.c'
  1904. then
  1905.     echo shar: "will not over-write existing file 'lbl.c'"
  1906. else
  1907. sed 's/^    X//' << \SHAR_EOF > 'lbl.c'
  1908.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  1909.     X *
  1910.     X *    Permission is hereby given to reproduce or modify this
  1911.     X *    software freely, provided that this notice be retained,
  1912.     X *    and that no use be made of the software for commercial
  1913.     X *    purposes without the express written permission of the
  1914.     X *    author.
  1915.     X */
  1916.     X
  1917.     X/* lbl.c:
  1918.     X *    main program - decode switches and arguments
  1919.     X *    and process each input file.
  1920.     X * usage:
  1921.     X *    lbl [ -d<char> ] [ -m<macro> ] [ -l ] [ -s ]
  1922.     X *        -d    <char> delimits in-line occurrences of a tag
  1923.     X *        -m    <macro> defines a tag value
  1924.     X *        -l    list label definitions
  1925.     X *        -s    suppress nroff output (implies -l)
  1926.     X * defaults:
  1927.     X *    -d@ -mL=
  1928.     X */
  1929.     X
  1930.     X#include    <lbl.h>
  1931.     X
  1932.     Xextern int    lflag;
  1933.     Xextern int    sflag;
  1934.     Xextern char    delimiter;
  1935.     Xextern char    macroname[];
  1936.     Xextern char    tempname[];
  1937.     Xextern char    *progname;
  1938.     Xextern FILE    *tempfile;
  1939.     X
  1940.     Xmain(argc, argv)
  1941.     X    us int    argc;
  1942.     X    char    *argv[];
  1943.     X{
  1944.     X    us int        decode();
  1945.     X    us int        nflags;
  1946.     X    FILE        *input;
  1947.     X    int        anydone        = 0;
  1948.     X    static char    standard[]    = "standard input";
  1949.     X
  1950.     X    if (argc != 0)
  1951.     X    {
  1952.     X        argc--;
  1953.     X        progname = *(argv++);
  1954.     X    }
  1955.     X    nflags = decode(argc, argv);
  1956.     X    argc -= nflags;
  1957.     X    argv += nflags;
  1958.     X
  1959.     X    /* Remaining arguments must be filenames; treat "-"
  1960.     X     * specially as standard input.
  1961.     X     * If no arguments, use atandard input.
  1962.     X     */
  1963.     X
  1964.     X    /* Pass 1: copy to temp file, building table of tags */
  1965.     X    if (!sflag)
  1966.     X    {
  1967.     X        mktemp(tempname);
  1968.     X        if ((tempfile=fopen(tempname, "w"))==NULL)
  1969.     X            fatal("cannot make temporary file");
  1970.     X        setsignals();
  1971.     X    }
  1972.     X    if (argc == 0)
  1973.     X    {
  1974.     X        scan(standard, stdin);
  1975.     X        anydone = 1;
  1976.     X    }
  1977.     X    else
  1978.     X    {
  1979.     X        while (argc != 0)
  1980.     X        {
  1981.     X            if (strcmp(argv[0], "-") == 0)
  1982.     X            {
  1983.     X                anydone = 1;
  1984.     X                scan(standard, stdin);
  1985.     X            }
  1986.     X            else
  1987.     X            {
  1988.     X                if ((input=fopen(argv[0], "r")) == NULL)
  1989.     X                    error("cannot open %s", argv[0]);
  1990.     X                else
  1991.     X                {
  1992.     X                    anydone = 1;
  1993.     X                    scan(argv[0], input);
  1994.     X                    fclose(input);
  1995.     X                }
  1996.     X            }
  1997.     X            argc--;
  1998.     X            argv++;
  1999.     X        }
  2000.     X    }
  2001.     X    if (!sflag)
  2002.     X        fclose(tempfile);
  2003.     X    if (lflag)
  2004.     X        listdefs();
  2005.     X
  2006.     X    /* Pass 2: translate tags */
  2007.     X
  2008.     X    if (!anydone)
  2009.     X    {
  2010.     X        unlink(tempname);
  2011.     X        exit(3);
  2012.     X    }
  2013.     X    if (!sflag)
  2014.     X    {
  2015.     X        if ((tempfile=fopen(tempname, "r")) == NULL)
  2016.     X            fatal("temporary file vanished before rescan!");
  2017.     X        rescan();
  2018.     X        unlink(tempname);
  2019.     X    }
  2020.     X    exit(0);
  2021.     X}
  2022.     X
  2023.     X/* Decode argument list */
  2024.     Xus int
  2025.     Xdecode(argc, argv)
  2026.     X    us int    argc;
  2027.     X    char    *argv[];
  2028.     X{
  2029.     X    int    nflags = 0;
  2030.     X
  2031.     X    while (argc != 0)
  2032.     X    {
  2033.     X        if (argv[0][0] != '-')
  2034.     X            return nflags;
  2035.     X        switch (argv[0][1])
  2036.     X        {
  2037.     X            case 'd':
  2038.     X                if ((delimiter=argv[0][2]) == '\0')
  2039.     X                    fatal("missing delimiter after -d");
  2040.     X                if (argv[0][3] != '\0')
  2041.     X                    fatal("delimiter must be 1 character");
  2042.     X                break;
  2043.     X            case 'm':
  2044.     X                if ((macroname[0]=argv[0][2]) == '\0' ||
  2045.     X                    (macroname[1]=argv[0][3]) == '\0' ||
  2046.     X                    argv[0][4] != '\0')
  2047.     X                    fatal(
  2048.     X                        "macro name must be 2 characters");
  2049.     X                break;
  2050.     X            case 'l':
  2051.     X                lflag = 1;
  2052.     X                break;
  2053.     X            case 's':
  2054.     X                lflag = sflag = 1;
  2055.     X                break;
  2056.     X            default:
  2057.     X                fatal("unknown flag '%s'", argv[0]);
  2058.     X                /*NOTREACHED*/
  2059.     X        }
  2060.     X        argc--;
  2061.     X        argv++;
  2062.     X        nflags++;
  2063.     X    }
  2064.     X    return nflags;
  2065.     X}
  2066. SHAR_EOF
  2067. if test 2926 -ne "`wc -c < 'lbl.c'`"
  2068. then
  2069.     echo shar: "error transmitting 'lbl.c'" '(should have been 2926 characters)'
  2070. fi
  2071. fi
  2072. echo shar: "extracting 'list.c'" '(1066 characters)'
  2073. if test -f 'list.c'
  2074. then
  2075.     echo shar: "will not over-write existing file 'list.c'"
  2076. else
  2077. sed 's/^    X//' << \SHAR_EOF > 'list.c'
  2078.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2079.     X *
  2080.     X *    Permission is hereby given to reproduce or modify this
  2081.     X *    software freely, provided that this notice be retained,
  2082.     X *    and that no use be made of the software for commercial
  2083.     X *    purposes without the express written permission of the
  2084.     X *    author.
  2085.     X */
  2086.     X
  2087.     X/* list.c:
  2088.     X *    list definitions in verbose mode
  2089.     X */
  2090.     X
  2091.     X#include    <lbl.h>
  2092.     X
  2093.     Xextern char    *def_format;
  2094.     Xextern type    *typetable;
  2095.     X
  2096.     Xlistdefs()
  2097.     X{
  2098.     X    type    *tp;
  2099.     X
  2100.     X    if (typetable == NULL)
  2101.     X    {
  2102.     X        fprintf(stderr, "No labels defined\n");
  2103.     X        return;
  2104.     X    }
  2105.     X    for (tp = typetable; tp != NULL; tp = tp->t_next)
  2106.     X        listtype(tp);
  2107.     X}
  2108.     X
  2109.     Xlisttype(tp)
  2110.     X    type    *tp;
  2111.     X{
  2112.     X    label    *lp;
  2113.     X
  2114.     X    fprintf(stderr, "*** Type %s: format %s\n", tp->t_name,
  2115.     X        tp->t_format==def_format ? "default" : tp->t_format);
  2116.     X    if (tp->t_labels == NULL)
  2117.     X    {
  2118.     X        fprintf(stderr, "(No labels defined\n)");
  2119.     X        return;
  2120.     X    }
  2121.     X    for (lp = tp->t_labels; lp != NULL; lp = lp->l_next)
  2122.     X    {
  2123.     X        fprintf(stderr, "%-16.16s %-14.14s %-6D ",
  2124.     X                lp->l_name,
  2125.     X                lp->l_file,
  2126.     X                lp->l_line);
  2127.     X        printl(lp, stderr);
  2128.     X        putc('\n', stderr);
  2129.     X    }
  2130.     X    putc('\n', stderr);
  2131.     X}
  2132. SHAR_EOF
  2133. if test 1066 -ne "`wc -c < 'list.c'`"
  2134. then
  2135.     echo shar: "error transmitting 'list.c'" '(should have been 1066 characters)'
  2136. fi
  2137. fi
  2138. echo shar: "extracting 'printl.c'" '(2951 characters)'
  2139. if test -f 'printl.c'
  2140. then
  2141.     echo shar: "will not over-write existing file 'printl.c'"
  2142. else
  2143. sed 's/^    X//' << \SHAR_EOF > 'printl.c'
  2144.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2145.     X *
  2146.     X *    Permission is hereby given to reproduce or modify this
  2147.     X *    software freely, provided that this notice be retained,
  2148.     X *    and that no use be made of the software for commercial
  2149.     X *    purposes without the express written permission of the
  2150.     X *    author.
  2151.     X */
  2152.     X
  2153.     X/* printl.c:
  2154.     X *    print a label according to a format
  2155.     X */
  2156.     X
  2157.     X#include    <lbl.h>
  2158.     X
  2159.     Xprintl(lab, out)
  2160.     X    rg label    *lab;
  2161.     X    rg FILE        *out;
  2162.     X{
  2163.     X    rg format    f = lab->l_type->t_format;
  2164.     X    rg us int    i;
  2165.     X
  2166.     X    for (i = 0; i <= lab->l_bottom; i++)
  2167.     X    {
  2168.     X        while (*f)
  2169.     X        {
  2170.     X            if (*f != '%')
  2171.     X                putc(*f, out);
  2172.     X            else
  2173.     X                switch (*++f)
  2174.     X                {
  2175.     X                    default:
  2176.     X                        putc(*f, out);
  2177.     X                        break;
  2178.     X                    case '\0':
  2179.     X                        putc('%', out);
  2180.     X                        break;
  2181.     X                    case '0':
  2182.     X                        printd(lab->l_levels[i]-1, out);
  2183.     X                        f++;
  2184.     X                        goto loopend;
  2185.     X                    case '1':
  2186.     X                        printd(lab->l_levels[i], out);
  2187.     X                        f++;
  2188.     X                        goto loopend;
  2189.     X                    case 'i':
  2190.     X                    case 'I':
  2191.     X                        printr(*f, lab->l_levels[i],
  2192.     X                            out);
  2193.     X                        f++;
  2194.     X                        goto loopend;
  2195.     X                    case 'a':
  2196.     X                    case 'A':
  2197.     X                        printa(*f, lab->l_levels[i],
  2198.     X                            out);
  2199.     X                        f++;
  2200.     X                        goto loopend;
  2201.     X                }
  2202.     X            f++;
  2203.     X        }
  2204.     X        error("format too short to print label %s", lab->l_name);
  2205.     X        break;
  2206.     X    loopend:
  2207.     X        continue;
  2208.     X    }
  2209.     X}
  2210.     X
  2211.     X/* Print Decimal */
  2212.     Xprintd(n, out)
  2213.     X    us int    n;
  2214.     X    FILE    *out;
  2215.     X{
  2216.     X    fprintf(out, "%u", n);
  2217.     X}
  2218.     X
  2219.     X/* Print Alphabetic 
  2220.     X *    actually base 26 (digits a-z), displaced by 1!
  2221.     X *    a is either "a" or "A" for upper or lower case.
  2222.     X */
  2223.     Xprinta(a, n, out)
  2224.     X    char    a;
  2225.     X    us int    n;
  2226.     X    FILE    *out;
  2227.     X{
  2228.     X    if (n==0)
  2229.     X        putc('0', out);
  2230.     X    else
  2231.     X        auxprinta(a, n-1, out);
  2232.     X}
  2233.     X    
  2234.     Xauxprinta(a, n, out)
  2235.     X    char    a;
  2236.     X    us int    n;
  2237.     X    FILE    *out;
  2238.     X{
  2239.     X    if (n > 25)
  2240.     X        auxprinta(a, n/26 - 1, out);
  2241.     X    putc(a + n%26, out);
  2242.     X}
  2243.     X
  2244.     X/* Print Roman
  2245.     X *    a is either "a" or "A" for upper or lower case.
  2246.     X */
  2247.     Xprintr(a, n, out)
  2248.     X    char    a;
  2249.     X    us int    n;
  2250.     X    FILE    *out;
  2251.     X{
  2252.     X    if (n==0)
  2253.     X    {
  2254.     X        putc('0', out);
  2255.     X        return;
  2256.     X    }
  2257.     X    if (n >= 50000)
  2258.     X    {
  2259.     X        putc('!', out);
  2260.     X        return;
  2261.     X    }
  2262.     X    while (n >= 10000)
  2263.     X        putc(a+('Z'-'I'), out), n -= 10000;
  2264.     X    if (n >= 9000)
  2265.     X        putc(a+('M'-'I'), out), putc(a+('Z'-'I'), out), n -= 9000;
  2266.     X    if (n >= 5000)
  2267.     X        putc(a+('W'-'I'), out), n -= 5000;
  2268.     X    if (n >= 4000)
  2269.     X        putc(a+('M'-'I'), out), putc(a+('W'-'I'), out), n -= 4000;
  2270.     X    while (n >= 1000)
  2271.     X        putc(a+('M'-'I'), out), n -= 1000;
  2272.     X    if (n >= 900)
  2273.     X        putc(a+('C'-'I'), out), putc(a+('M'-'I'), out), n -= 900;
  2274.     X    if (n >= 500)
  2275.     X        putc(a+('D'-'I'), out), n -= 500;
  2276.     X    if (n >= 400)
  2277.     X        putc(a+('C'-'I'), out), putc(a+('D'-'I'), out), n -= 400;
  2278.     X    while (n >= 100)
  2279.     X        putc(a+('C'-'I'), out), n -= 100;
  2280.     X    if (n >= 90)
  2281.     X        putc(a+('X'-'I'), out), putc(a+('C'-'I'), out), n -= 90;
  2282.     X    if (n >= 50)
  2283.     X        putc(a+('L'-'I'), out), n -= 50;
  2284.     X    if (n >= 40)
  2285.     X        putc(a+('X'-'I'), out), putc(a+('L'-'I'), out), n -= 40;
  2286.     X    while (n >= 10)
  2287.     X        putc(a+('X'-'I'), out), n -= 10;
  2288.     X    if (n >= 9)
  2289.     X        putc(a+('I'-'I'), out), putc(a+('X'-'I'), out), n -= 9;
  2290.     X    if (n >= 5)
  2291.     X        putc(a+('V'-'I'), out), n -= 5;
  2292.     X    if (n >= 4)
  2293.     X        putc(a+('I'-'I'), out), putc(a+('V'-'I'), out), n -= 4;
  2294.     X    while (n >= 1)
  2295.     X        putc(a+('I'-'I'), out), n -= 1;
  2296.     X}
  2297. SHAR_EOF
  2298. if test 2951 -ne "`wc -c < 'printl.c'`"
  2299. then
  2300.     echo shar: "error transmitting 'printl.c'" '(should have been 2951 characters)'
  2301. fi
  2302. fi
  2303. echo shar: "extracting 'rescan.c'" '(2630 characters)'
  2304. if test -f 'rescan.c'
  2305. then
  2306.     echo shar: "will not over-write existing file 'rescan.c'"
  2307. else
  2308. sed 's/^    X//' << \SHAR_EOF > 'rescan.c'
  2309.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2310.     X *
  2311.     X *    Permission is hereby given to reproduce or modify this
  2312.     X *    software freely, provided that this notice be retained,
  2313.     X *    and that no use be made of the software for commercial
  2314.     X *    purposes without the express written permission of the
  2315.     X *    author.
  2316.     X */
  2317.     X
  2318.     X/* rescan.c:
  2319.     X *    read temporary file, substituting for defined labels
  2320.     X */
  2321.     X
  2322.     X#include    <lbl.h>
  2323.     X#include    <ctype.h>
  2324.     X
  2325.     Xextern char    delimiter;
  2326.     Xextern char    *filename;
  2327.     Xextern FILE    *tempfile;
  2328.     Xextern long    fileline;
  2329.     X
  2330.     Xint    translate = 1;
  2331.     X
  2332.     Xrescan()
  2333.     X{
  2334.     X    rg int    c;
  2335.     X        /* Keep tempfile, delimiter and translate flag in registers to
  2336.     X         * speed up this routine; the last two need to be reloaded after
  2337.     X         * and only after calls to domagic()
  2338.     X         */
  2339.     X    rg FILE *tf = tempfile;
  2340.     X    rg int    dlm = delimiter;
  2341.     X    rg int    tr = translate;
  2342.     X
  2343.     X    while ((c = getc(tf)) != EOF)
  2344.     X    {
  2345.     X        if (c == MAGIC1)
  2346.     X        {
  2347.     X            if ((c = getc(tf)) == MAGIC2)
  2348.     X            {
  2349.     X                domagic();
  2350.     X                dlm = delimiter;
  2351.     X                tr = translate;
  2352.     X                continue;
  2353.     X            }
  2354.     X            else
  2355.     X                ungetc(c, tf);
  2356.     X        }
  2357.     X        if (c == dlm && tr)
  2358.     X        {
  2359.     X            doreplace();
  2360.     X            continue;
  2361.     X        }
  2362.     X        if (c == '\n')
  2363.     X            fileline++;
  2364.     X        putchar(c);
  2365.     X    }
  2366.     X}
  2367.     X
  2368.     Xdomagic()
  2369.     X{
  2370.     X    int        c;
  2371.     X    static char    buffer[BUFSIZ];
  2372.     X
  2373.     X    switch (getc(tempfile))
  2374.     X    {
  2375.     X        case M_DELIM:
  2376.     X            c = getc(tempfile);
  2377.     X            if (c == '\n')
  2378.     X                translate = 0;
  2379.     X            else
  2380.     X            {
  2381.     X                translate = 1;
  2382.     X                delimiter = c;
  2383.     X                getc(tempfile);
  2384.     X            }
  2385.     X            break;
  2386.     X        case M_FILE:
  2387.     X            fgets(buffer, BUFSIZ, tempfile);
  2388.     X            buffer[strlen(buffer)-1] = '\0';
  2389.     X            filename = buffer;
  2390.     X            fileline = 1;
  2391.     X            break;
  2392.     X    }
  2393.     X}
  2394.     X
  2395.     Xdoreplace()
  2396.     X{
  2397.     X    rg int        c;
  2398.     X    char        typename[BUFSIZ];
  2399.     X    char        labelname[BUFSIZ];
  2400.     X    rg type        *tp;
  2401.     X    rg label    *lp;
  2402.     X
  2403.     X    /* <delimiter><delimiter> gives <delimiter> as output */
  2404.     X    if ((c = getc(tempfile)) == delimiter)
  2405.     X    {
  2406.     X        putchar(delimiter);
  2407.     X        return;
  2408.     X    }
  2409.     X    ungetc(c, tempfile);
  2410.     X    getword(typename);
  2411.     X    getword(labelname);
  2412.     X    if ((c = getc(tempfile)) != delimiter)
  2413.     X    {
  2414.     X        error("malformed label reference");
  2415.     X        while (c != delimiter)
  2416.     X        {
  2417.     X            if (c == EOF || c == '\n')
  2418.     X                break;
  2419.     X            c = getc(tempfile);
  2420.     X        }
  2421.     X        return;
  2422.     X    }
  2423.     X    if ((tp = findtype(typename, 0)) == NULL)
  2424.     X    {
  2425.     X        error("undefined type '%s'", typename);
  2426.     X        printf("<<%s %s>>", typename, labelname);
  2427.     X        return;
  2428.     X    }
  2429.     X    if ((lp = findlabel(tp, labelname)) == NULL)
  2430.     X    {
  2431.     X        error("undefined label '%s'", labelname);
  2432.     X        printf("<<%s %s>>", typename, labelname);
  2433.     X        return;
  2434.     X    }
  2435.     X    printl(lp, stdout);
  2436.     X}
  2437.     X
  2438.     Xgetword(buffer)
  2439.     X    rg char    *buffer;
  2440.     X{
  2441.     X    rg int    c;
  2442.     X    rg int    dlm = delimiter;
  2443.     X    rg FILE *tf = tempfile;
  2444.     X
  2445.     X    c = getc(tf);
  2446.     X    while (isspace(c))
  2447.     X        c = getc(tf);
  2448.     X    while (c != dlm && !isspace(c) && c != '\n' && c != EOF)
  2449.     X    {
  2450.     X        *buffer++ = c;
  2451.     X        c = getc(tf);
  2452.     X    }
  2453.     X    *buffer = '\0';
  2454.     X    if (!isspace(c) && c != EOF)
  2455.     X        ungetc(c, tf);
  2456.     X}
  2457. SHAR_EOF
  2458. if test 2630 -ne "`wc -c < 'rescan.c'`"
  2459. then
  2460.     echo shar: "error transmitting 'rescan.c'" '(should have been 2630 characters)'
  2461. fi
  2462. fi
  2463. echo shar: "extracting 'scan.c'" '(3478 characters)'
  2464. if test -f 'scan.c'
  2465. then
  2466.     echo shar: "will not over-write existing file 'scan.c'"
  2467. else
  2468. sed 's/^    X//' << \SHAR_EOF > 'scan.c'
  2469.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2470.     X *
  2471.     X *    Permission is hereby given to reproduce or modify this
  2472.     X *    software freely, provided that this notice be retained,
  2473.     X *    and that no use be made of the software for commercial
  2474.     X *    purposes without the express written permission of the
  2475.     X *    author.
  2476.     X */
  2477.     X
  2478.     X/* scan.c:
  2479.     X *    scan an input file, recording label-definitions, etc.
  2480.     X *    All special actions are introduced by a line starting
  2481.     X *        .<macro>
  2482.     X *    where <macro> is "L=" unless redefined in the command-line.
  2483.     X *    Actions are
  2484.     X *        .L= <type> <level> <label>
  2485.     X *            define <label> by incrementing the <level>th
  2486.     X *            index of label-type <type>, e.g.
  2487.     X *            .L= table 1 profits_1983
  2488.     X *        .L= delimiter <char>
  2489.     X *            redefines the delimiter for the subsequent text.
  2490.     X *        .L= format <type> <string>
  2491.     X *            defines a format for displaying the given label <type>;
  2492.     X *            the latest definition in the input will be used for
  2493.     X *            ALL occurrences, including preceding ones.
  2494.     X *            e.g.
  2495.     X *            .L= format appendix %A-%1
  2496.     X *        .L= next <type> <value> <value> ...
  2497.     X *            set the value of the next label generated for <type>;
  2498.     X *            the <value>s give successive levels, with omitted
  2499.     X *            trailing values defaulting to 0.
  2500.     X */
  2501.     X
  2502.     X#include    <lbl.h>
  2503.     X#include    <ctype.h>
  2504.     X
  2505.     Xextern char    macroname[];
  2506.     Xextern char    *filename;
  2507.     Xextern int    sflag;
  2508.     Xextern FILE    *tempfile;
  2509.     Xextern long    fileline;
  2510.     X
  2511.     Xscan(fname, f)
  2512.     X    rg char    *fname;
  2513.     X    rg FILE    *f;
  2514.     X{
  2515.     X    char    line[BUFSIZ];
  2516.     X    rg int    line_complete = 1;
  2517.     X
  2518.     X    /* Mark start of file in temp file */
  2519.     X    if (!sflag)
  2520.     X        fprintf(tempfile, "%c%c%c%s\n", MAGIC1, MAGIC2, M_FILE, fname);
  2521.     X    filename = fname;
  2522.     X    fileline = 0L;
  2523.     X
  2524.     X    while (fgets(line, BUFSIZ, f) != NULL)
  2525.     X    {
  2526.     X        if (!sflag)
  2527.     X            fputs(line, tempfile);
  2528.     X        if (line_complete)
  2529.     X        {
  2530.     X            fileline++;
  2531.     X            line_complete = line[strlen(line)-1] == '\n';
  2532.     X            if (line[0]=='.' && line[1]==macroname[0] &&
  2533.     X                line[2]==macroname[1])
  2534.     X            {
  2535.     X                if (line_complete)
  2536.     X                    process(line+3);
  2537.     X                else
  2538.     X                    error(".%s line too long", macroname);
  2539.     X            }
  2540.     X        }
  2541.     X        else
  2542.     X            line_complete = line[strlen(line)-1] == '\n';
  2543.     X    }
  2544.     X}
  2545.     X
  2546.     Xprocess(line)
  2547.     X    char    *line;
  2548.     X{
  2549.     X    us int    split();
  2550.     X    keyword    *findkeyword();
  2551.     X    us int    nargs;
  2552.     X    char    *argvec[NLEVELS+2];
  2553.     X    keyword    *key;
  2554.     X
  2555.     X    if ((nargs = split(line, argvec)) == 0)
  2556.     X    {
  2557.     X        error("empty .%s line", macroname);
  2558.     X        return;
  2559.     X    }
  2560.     X
  2561.     X    /* Check for and act upon reserved words */
  2562.     X    if ((key = findkeyword(argvec[0])) != NULL)
  2563.     X    {
  2564.     X        if (nargs < key->k_minargs)
  2565.     X        {
  2566.     X            error("%s - too few arguments", key->k_name);
  2567.     X            return;
  2568.     X        }
  2569.     X        if (nargs > key->k_maxargs)
  2570.     X        {
  2571.     X            error("%s - too many arguments", key->k_name);
  2572.     X            return;
  2573.     X        }
  2574.     X        (*(key->k_action))(nargs, argvec);
  2575.     X        return;
  2576.     X    }
  2577.     X
  2578.     X    /* Process a label definition */
  2579.     X    if (nargs != 3)
  2580.     X    {
  2581.     X        error("too %s arguments in label definition",
  2582.     X            nargs < 3 ? "few" : "many");
  2583.     X        return;
  2584.     X    }
  2585.     X    addlbl(argvec[0], argvec[1], argvec[2]);
  2586.     X}
  2587.     X
  2588.     X/* split - split a line into arguments
  2589.     X *    N.B. successive calls of this invalidate earlier calls;
  2590.     X *    argvec is set to point to strings within the
  2591.     X *    static local buffer "copybuf" which is overwritten on
  2592.     X *    each call.
  2593.     X */
  2594.     Xus int
  2595.     Xsplit(line, argvec)
  2596.     X    char    *line;
  2597.     X    char    *argvec[];
  2598.     X{
  2599.     X    us int        nargs = 0;
  2600.     X    static char    copybuf[BUFSIZ];
  2601.     X    char        *ln = copybuf;
  2602.     X
  2603.     X    strcpy(ln, line);
  2604.     X    while (*ln)
  2605.     X    {
  2606.     X        while (isspace(*ln))
  2607.     X            ln++;
  2608.     X        if (*ln)
  2609.     X        {
  2610.     X            if (nargs > 2+NLEVELS)
  2611.     X            {
  2612.     X                error("surplus arguments to .%s ignored",
  2613.     X                    macroname);
  2614.     X                break;
  2615.     X            }
  2616.     X            argvec[nargs++] = ln;
  2617.     X            while (*ln && !isspace(*ln))
  2618.     X                ln++;
  2619.     X            if (*ln)
  2620.     X                *ln++ = '\0';
  2621.     X        }
  2622.     X    }
  2623.     X    if (nargs > 2+NLEVELS)
  2624.     X        nargs = 2+NLEVELS;
  2625.     X    return nargs;
  2626.     X}
  2627. SHAR_EOF
  2628. if test 3478 -ne "`wc -c < 'scan.c'`"
  2629. then
  2630.     echo shar: "error transmitting 'scan.c'" '(should have been 3478 characters)'
  2631. fi
  2632. fi
  2633. echo shar: "extracting 'signals.c'" '(845 characters)'
  2634. if test -f 'signals.c'
  2635. then
  2636.     echo shar: "will not over-write existing file 'signals.c'"
  2637. else
  2638. sed 's/^    X//' << \SHAR_EOF > 'signals.c'
  2639.     X/* (C) C.D.F. Miller, Heriot-Watt University, March 1984
  2640.     X *
  2641.     X *    Permission is hereby given to reproduce or modify this
  2642.     X *    software freely, provided that this notice be retained,
  2643.     X *    and that no use be made of the software for commercial
  2644.     X *    purposes without the express written permission of the
  2645.     X *    author.
  2646.     X */
  2647.     X
  2648.     X/* signals.c:
  2649.     X *    provide clean-up after trapping external signals
  2650.     X */
  2651.     X
  2652.     X#include    <lbl.h>
  2653.     X#include    <signal.h>
  2654.     X
  2655.     Xextern char    tempname[];
  2656.     X
  2657.     Xint
  2658.     Xonsignal()
  2659.     X{
  2660.     X    unlink(tempname);
  2661.     X    _exit(2);
  2662.     X}
  2663.     X
  2664.     Xsetsignals()
  2665.     X{
  2666.     X    int    (*oldsig)();
  2667.     X
  2668.     X    if ((oldsig=signal(SIGINT, onsignal)) == SIG_IGN)
  2669.     X        signal(SIGINT, SIG_IGN);
  2670.     X    if ((oldsig=signal(SIGQUIT, onsignal)) == SIG_IGN)
  2671.     X        signal(SIGQUIT, SIG_IGN);
  2672.     X    if ((oldsig=signal(SIGHUP, onsignal)) == SIG_IGN)
  2673.     X        signal(SIGHUP, SIG_IGN);
  2674.     X    if ((oldsig=signal(SIGTERM, onsignal)) == SIG_IGN)
  2675.     X        signal(SIGTERM, SIG_IGN);
  2676.     X}
  2677. SHAR_EOF
  2678. if test 845 -ne "`wc -c < 'signals.c'`"
  2679. then
  2680.     echo shar: "error transmitting 'signals.c'" '(should have been 845 characters)'
  2681. fi
  2682. fi
  2683. echo shar: "extracting 'Make.log'" '(431 characters)'
  2684. if test -f 'Make.log'
  2685. then
  2686.     echo shar: "will not over-write existing file 'Make.log'"
  2687. else
  2688. sed 's/^    X//' << \SHAR_EOF > 'Make.log'
  2689.     Xcc -O -I../hdr -c lbl.c
  2690.     Xcc -O -I../hdr -c actions.c
  2691.     Xcc -O -I../hdr -c build.c
  2692.     Xcc -O -I../hdr -c error.c
  2693.     Xcc -O -I../hdr -c externs.c
  2694.     Xcc -O -I../hdr -c find.c
  2695.     Xcc -O -I../hdr -c keyword.c
  2696.     Xcc -O -I../hdr -c list.c
  2697.     Xcc -O -I../hdr -c printl.c
  2698.     Xcc -O -I../hdr -c rescan.c
  2699.     Xcc -O -I../hdr -c scan.c
  2700.     Xcc -O -I../hdr -c signals.c
  2701.     Xcc -o lbl -i lbl.o actions.o build.o error.o externs.o find.o keyword.o list.o printl.o rescan.o scan.o signals.o
  2702. SHAR_EOF
  2703. if test 431 -ne "`wc -c < 'Make.log'`"
  2704. then
  2705.     echo shar: "error transmitting 'Make.log'" '(should have been 431 characters)'
  2706. fi
  2707. fi
  2708. echo shar: "done with directory 'src'"
  2709. cd ..
  2710. exit 0
  2711. #    End of shell archive
  2712.  
  2713. --
  2714. Larry Campbell                             The Boston Software Works, Inc.
  2715. ARPA: campbell%maynard.uucp@harvard.ARPA   120 Fulton Street, Boston MA 02109
  2716. UUCP: {alliant,wjh12}!maynard!campbell     (617) 367-6846
  2717.  
  2718.